0

I have created android app, that uses Bluemix SQLDB service. For this am using node.js to interact with SQL database. To interact my android app with node.js am using RESTful API because i need to store edit-text parameters in SQL database. Can anyone help me how do pass my edit-text variables such as Name, Email and Password to node.js to insert into 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 Code:

   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);

// after this it should use RESTAPI to connect to insert into SQLDB service in Bluemix through node.js

Santhosh S
  • 99
  • 2
  • 7
  • Check out this post http://stackoverflow.com/questions/5769549/how-send-http-request-in-android-app-to-access-rest-api – Jeff Sloyer Apr 07 '15 at 14:40

2 Answers2

0

Check out this example project (https://hub.jazz.net/project/pvanrun/SQLDBJava/overview) on how to connect to SQLDB from Java.

Jeff Sloyer
  • 4,899
  • 1
  • 24
  • 48
  • Yeah this for Web application, not for mobile app. As i know, we can't directly connect to Bluemix SQLDB from android app, for this am using RESTAPI/node.js to connect SQLDB. Can you tell me how do i send or insert my edit-text fields to SQLDB through RESTAPI?. I already connected to SQLDB from node.js, now i need connect between my android app to node,js – Santhosh S Apr 07 '15 at 07:04
  • I would create a REST API and then call the REST API from your Android app. – Jeff Sloyer Apr 07 '15 at 14:02
  • Can you tell me how can i send those edittext field such as Name, Email and Password to node.js through RESTAPI? because am beginner.... – Santhosh S Apr 07 '15 at 14:30
0

It might be worth taking a look at this Developer Works Question, How the android app make a RESTAPI call to the bluemix deployed node.js app which takes that request and connects to sqldb?.

They use a custom node.js app to connect to SQL DB upon appropriate REST calls from their Android device.

Dave Cariello
  • 505
  • 6
  • 12