How to insert values into Android SQLite Database?

105 views Asked by At

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

There are 0 answers