0

I have created a database in which first three columns are empty. I have to insert values to them later. When i use update query onItemClick event it gets inserted. When i click again first three columns updated again. I just want to update only once. My Code is

 Cursor cursor= db.rawQuery("select uSerialNo,dealerCode from unittable", null);
               cursor.moveToFirst();
                String srNo=cursor.getString(0);
                String drCode=cursor.getString(1);
                if (srNo.equals(sNo) || drCode.equals(dCode)){
                    ContentValues cv=new ContentValues();
                    cv.put("userName",user);
                    cv.put("mobileNo", address);
                    cv.put("address", addrs);
                   db.update("unittable", cv, "uSerialNo='" + srNo + "'", null);
                    db.update("unittable", cv, "uSerialNo='" + srNo + "'", null);
                    db.update("unittable", cv, "uSerialNo+'" + srNo + "'", null);
                    smsManager.sendTextMessage(address,null,"YES. ACTIVATE. Default Password is 1234",null,null);
                } else {
                    Toast.makeText(ActivationActivity.this,"Failed",Toast.LENGTH_LONG).show();
                    smsManager.sendTextMessage(address,null,"NO. Details or Incorrect. Check the details or Call the Customer Care",null,null);
                }
3
  • possible duplicate of Inserting values to SQLite table in Android Commented Jun 9, 2015 at 7:29
  • post your update method and please specify the error you are seeing. Commented Jun 9, 2015 at 7:42
  • i don't see any error. i got my previously entered values updated. but i don't want to get updated. Commented Jun 9, 2015 at 7:58

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.