插入值操作后如何从服务器获取自动递增值

时间:2015-09-16 06:55:30

标签: java android mysql sqlite

我是android的新手,我用json在MySQL数据库中插入了一些值。当我在DB中插入值,然后用户id填充自动增量操作,我想在插入操作后得到这个id,并希望用sqlite将其保存在本地数据库中。我该怎么做呢?

 params.add(new BasicNameValuePair("police_verified", uname));
 params.add(new BasicNameValuePair("timezone", p_mobile));
 params.add(new BasicNameValuePair("fb_id", p_mobile));
 params.add(new BasicNameValuePair("gid", p_mobile));
 params.add(new BasicNameValuePair("service_provider_bit", ""));


 // getting JSON Object
 // Note that create product url accepts POST method
 JSONObject json = jsonParser.makeHttpRequest(url_create_users, "POST", params);

 // check log cat fro response
 Log.d("Create Response", json.toString());

 // check for success tag
 try {
     int success = json.getInt(TAG_SUCCESS);

     if (success == 1) {
       //Save in to Local DB
       mHelper = new MyDbHelper(InsertInfoActivity.this);
       mHelper.open();
       boolean isSaved = AddData();


       if(isSaved=true) {
          InsertInfoActivity.this.runOnUiThread(new Runnable() {
             public void run() {
                Toast.makeText(InsertInfoActivity.this, "Data inserted", Toast.LENGTH_LONG).show();
             }
           }
        );

0 个答案:

没有答案