title: How to Send All SQLite Data to online Server
body: <p>I am <strong><em>storing data into SQLiteDatabase</em></strong> which is stored into SD Card, now i <strong>have to send all SQLite data to server</strong>.
  Note: I have <strong>created same fields to server database</strong> as well (<strong>simillar</strong> to SQLite DB) for an eg: <strong>PersonName</strong></p>
  
  <p>Below code i used to check, am i able <strong>to store data to server</strong> (for testing purpose - i <strong>accepted data by user into edittext</strong>) and then <strong><em>sent to server</em></strong>, and i <strong>was successful</strong> in that.</p>
  
  <pre><code>String url = "http://localhost/ChurchData.php";                                         
  List&lt;NameValuePair&gt; params = new ArrayList&lt;NameValuePair&gt;();
  params.add(new BasicNameValuePair("sPersonName", editPersonName.getText().toString()));
  String resultServer  = getHttpPost(url,params);
  Log.d("Entire string::", " " + resultServer);
  
  /*** Default Value ***/
  strStatusID = "0";
  strError = "";
  
  JSONObject c;
  try {
  c = new JSONObject(resultServer);
  strStatusID = c.getString("StatusID");
  strError = c.getString("Message");
  } catch (JSONException e) {
  // TODO Auto-generated catch block
  e.printStackTrace();
   }
   // prepare save data
   if(strStatusID.equals("0"))
   {
  Toast.makeText(getApplicationContext(), "Already Exist !", Toast.LENGTH_LONG).show();
   }
   else
   {
  Toast.makeText(getApplicationContext(), "Data Uploaded Successfully!", Toast.LENGTH_SHORT).show();                          
   }
   return true;
  }
  
  private String getHttpPost(String url,
   List&lt;NameValuePair&gt; params) {
   StringBuilder str = new StringBuilder();
   HttpClient client = new DefaultHttpClient();
   HttpPost httpPost = new HttpPost(url);
   try {
  httpPost.setEntity(new UrlEncodedFormEntity(params));
  HttpResponse response = client.execute(httpPost);
  StatusLine statusLine = response.getStatusLine();
  int statusCode = statusLine.getStatusCode();
  if (statusCode == 200) { // Status OK
  HttpEntity entity = response.getEntity();
  InputStream content = entity.getContent();
  BufferedReader reader = new BufferedReader(new InputStreamReader(content));
  String line;
  while ((line = reader.readLine()) != null) {
  str.append(line);
  }
  } else {
  Log.e("Log", "Failed to download result..");
  }
  } catch (ClientProtocolException e) {
      e.printStackTrace();
  } catch (IOException e) {
  e.printStackTrace();
  }
   return str.toString();
  }
  </code></pre>
  
  <p>So may i know, <strong><em>How can i send SQLite database records to server</em></strong> ? My <strong>database class</strong> looks like this:</p>
  
  <pre><code>public class myDBClasss extends SQLiteOpenHelper {
  
      // Database Version
      private static final int DATABASE_VERSION = 2;
      // Database Name
      private static final String DATABASE_NAME = "ChurchDB";
      // Table Name
      private static final String TABLE_MEMBER = "DataTable";
  
      public myDBClasss(Context context) {
          // to store data into SD Card   
         super(context, Environment.getExternalStorageDirectory()
                  + File.separator + "ChurchData"
                  + File.separator + DATABASE_NAME, null, DATABASE_VERSION);
      }
  
      @Override
      public void onCreate(SQLiteDatabase db) {
          // TODO Auto-generated method stub
          // Create Table Name
          db.execSQL("CREATE TABLE " + TABLE_MEMBER + 
                    "(PersonName VARCHAR(100)," +
                    " PersonEmail VARCHAR(100)," +
                    " PersonTelephone VARCHAR(100)," +
                    " Newsletter VARCHAR(100));");       // checkbox
  
          Log.d("CREATE TABLE","Create Table Successfully - classs");
      }
  
      // Insert Data
      public long insertData(String strPersonName, String strPersonEmail, String strPersonTelephone, String strNewsletter) {
          // TODO Auto-generated method stub
  
           try {
              SQLiteDatabase db;
              db = this.getWritableDatabase(); // Write Data
  
              ContentValues Val = new ContentValues(); 
              Val.put("PersonName", strPersonName);
              Val.put("PersonEmail", strPersonEmail);
              Val.put("PersonTelephone", strPersonTelephone);
              Val.put("Newsletter", strNewsletter);       // checkbox
  
              long rows = db.insert(TABLE_MEMBER, null, Val);
  
              db.close();
              return rows; // return rows inserted.
  
           } catch (Exception e) {
              return -1;
           }
      }
  
      // Update Data
      public long updateData(String strPersonName, String strPersonEmail, String strPersonTelephone, String strNewsletter){
      // TODO Auto-generated method stub
  
          try {
              SQLiteDatabase db;
              db = this.getWritableDatabase(); // Write Data
  
              ContentValues Val = new ContentValues();
              Val.put("PersonName", strPersonName);
              Val.put("PersonEmail", strPersonEmail);
                      Val.put("PersonTelephone", strPersonTelephone);
              Val.put("Newsletter", strNewsletter);       // checkbox
  
              long rows = db.update(TABLE_MEMBER, Val, "PersonName=?",
                      new String[] { String.valueOf(strPersonName) });
  
              db.close();
              return rows; // return rows updated.
  
          } catch (Exception e) {
              return -1;
          }   
      }
  
      // Fetch data
      public String[] selectData(String strPersonName) {
          // TODO Auto-generated method stub
  
           try {
              String arrData[] = null;    
  
               SQLiteDatabase db;
               db = this.getReadableDatabase(); // Read Data
  
               Cursor cursor = db.query(TABLE_MEMBER, new String[] { "*" }, 
                          "PersonName=?",
                          new String[] { String.valueOf(strPersonName) }, null, null, null, null);
  
                  if(cursor != null)
                  {
                      if (cursor.moveToFirst()) {
                          arrData = new String[cursor.getColumnCount()];
  
                          arrData[0] = cursor.getString(0);
                          arrData[1] = cursor.getString(1);
                          arrData[2] = cursor.getString(2);
                          arrData[3] = cursor.getString(3);       // checkbox
                      }
                  }
                  cursor.close();
                  db.close();
                  return arrData;
  
           } catch (Exception e) {
              return null;
           }
      }
  
      // Check for data(s) using PersonName field
      public boolean exists(String strImageName) {
             SQLiteDatabase db;
             db = this.getReadableDatabase(); // Read Data
             Cursor cursor = db.rawQuery("select 1 from DataTable where PersonName= ?", 
                  new String[] { strImageName });
             boolean exists = (cursor.getCount() &gt; 0);
             cursor.close();
             return exists;
      }
  
  
      @Override
      public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
          // TODO Auto-generated method stub
          db.execSQL("DROP TABLE IF EXISTS " + TABLE_MEMBER);
          // Re Create on method  onCreate
          onCreate(db);
      }
  
  }
  </code></pre>