lundi 12 octobre 2015

Insert value into same row but different column

good day everyone. I'm new to android and now using cursor to check whether the specific column is null or not. If is null, the value will be inserted into selected column. The code work fine actually, but they are inserted into two different row. How can I solve that so that value c and d will insert into same row but different column?

 public void checkRow1(String a, String b, String c, String d)
    {
        WD.insertWorkDetails(a1, a, b, c, d);
        Cursor mCursor = database.rawQuery("SELECT TimeOut_Info FROM " + MyDatabaseHelper.TABLE_INFO + " WHERE " +
                MyDatabaseHelper.TimeOut_Info + "= '" + d + "'", null);
        if (mCursor == null) {
            database=dbHelper.getWritableDatabase();
            ContentValues values = new ContentValues();
            values.put(MyDatabaseHelper.TimeOut_Info, d);
            database.insert(MyDatabaseHelper.TABLE_INFO, null, values);
            return ;

        }
             database=dbHelper.getWritableDatabase();
            ContentValues values = new ContentValues();
            values.put(MyDatabaseHelper.TimeIn_Info, c);
            database.insert(MyDatabaseHelper.TABLE_INFO, null, values);
        Toast.makeText(getApplicationContext(), "Data Saved", Toast.LENGTH_LONG).show();

        return;
    }

Aucun commentaire:

Enregistrer un commentaire