2015-04-02 19 views
0

我已经创建了使用Bluemix SQLDB服务的android应用程序。为此我使用node.js与SQL数据库进行交互。使用RESTful API与node.js交互我的android应用程序,因为我需要将编辑文本参数存储在SQL数据库中。任何人都可以帮助我如何将编辑文本变量(如名称,电子邮件和密码)传递给node.js以插入到SQLDB中。Android应用程序如何对Bluemix部署的node.js应用程序进行RESTAPI调用,该应用程序接受该请求并连接到sqldb?

<EditText 
     android:id="@+id/editTextreg5" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 

     android:ems="10" 
     android:hint="Full Name" 
     android:layout_marginRight="15dp" 
     android:layout_marginLeft="15dp" 
     android:layout_marginTop="20dp" 
     android:textColor="#000000" 
     android:textSize="20dp" 
     android:inputType="textPersonName" > 
     <requestFocus /> 
    </EditText> 



    <EditText 
     android:id="@+id/editTextreg" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 

     android:ems="10" 
     android:hint="Short Id @ibm.com" 
     android:layout_marginRight="15dp" 
     android:layout_marginLeft="15dp" 
     android:layout_marginTop="20dp" 
     android:textColor="#000000" 
     android:textSize="20dp" 
     android:inputType="textEmailAddress" > 
     <requestFocus /> 
    </EditText> 



    <EditText 
     android:id="@+id/editTextreg2" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:ems="10" 
     android:hint="Password" 
     android:layout_marginRight="15dp" 
     android:layout_marginLeft="15dp" 
     android:textColor="#000000" 
     android:textSize="20dp" 
     android:inputType="textPassword" /> 

Java代码:

public class Regisrtation_page extends Activity { 

    protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_regisrtation_page); 
    Button breg1 = (Button) findViewById(R.id.buttonreg); 

    breg1.setOnClickListener(new View.OnClickListener() { 

     public void onClick(View v) { 

      final EditText Name =(EditText) findViewById(R.id.editTextreg5); 
      final EditText Email =(EditText) findViewById(R.id.editTextreg); 
      final EditText Passwd =(EditText) findViewById(R.id.editTextreg2); 

//在此之后它应该使用RESTAPI连接通过node.js的

+0

看看这个帖子http://stackoverflow.com/questions/5769549/how-send-http-request-in-android-app-to-access-rest-api – 2015-04-07 14:40:12

回答

0

看看这个例子项目插入SQLDB服务Bluemix(https://hub.jazz.net/project/pvanrun/SQLDBJava/overview)关于如何从Java连接到SQLDB。

+0

是的,这是为Web应用程序,不适用于手机应用程序。 据我所知,我们无法直接连接到Android应用程序的Bluemix SQLDB,因为我使用RESTAPI/node.js来连接SQLDB。你能告诉我如何通过RESTAPI发送或插入我的编辑文本字段到SQLDB吗? 我已经从node.js连接到SQLDB,现在我需要将我的android应用程序连接到节点,js – 2015-04-07 07:04:16

+0

我会创建一个REST API,然后从您的Android应用程序调用REST API。 – 2015-04-07 14:02:13

+0

你能告诉我如何通过RESTAPI发送edittext字段,例如Name,Email和Password给node.js吗? 因为是初学者.... – 2015-04-07 14:30:00

相关问题