lundi 2 mai 2016

Sq-lite Android Cursor does not work in specific column

I have one code that i want to export one value increment by one and store it back, i tried the way i do in every other function but for this i don't get something back with the cursor, i don't know if it's my SQL or something on the code, everything looks fine to me can't find the mistake.

All i know is that parousies_max keeps the value it has before the cursor.getString but it gets normally the +1

The Database is like this with only one input to check it for now

TABLE_NAME2=Mathimata_table
ID_MATHIMA:001 - ONOMA_MATHIMA:Pro1 - EXAMINO_MATHIMA:1 - PAROUSIES_MAX:0 - KLEIDI:4888

And my code is this :

final String SQL_EXAGOGH_PAROUSIES_MAX = final String SQL_EXAGOGH_PAROUSIES_MAX = 
"SELECT "+DatabaseHelper.Col_PAROUSIES_MAX+" 
 FROM "+DatabaseHelper.TABLE_NAME2+" 
 WHERE "+DatabaseHelper.Col_ID_MATHIMA+" = "+id_math;
    SQLiteDatabase sqLiteDatabase=this.getReadableDatabase();
    Cursor cursor = sqLiteDatabase.rawQuery(SQL_EXAGOGH_PAROUSIES_MAX,null);
    if (cursor.moveToFirst()) {
        do {
            parousies_max = cursor.getString(cursor.getColumnIndex("PAROUSIES_MAX"));
        }while (cursor.moveToNext());
    }
    cursor.close();
efedriko=Integer.parseInt(parousies_max);
efedriko=efedriko+1;
parousies_max=Integer.toString(efedriko);

  SQLiteDatabase db = this.getWritableDatabase();
        ContentValues contentValues = new ContentValues();
        contentValues.put("PAROUSIES_MAX",parousies_max);
        contentValues.put(Col_KLEIDI,kleidi );
        db.update(TABLE_NAME2, contentValues,"ID_MATHIMA = ?",new String[] {id_math});

Aucun commentaire:

Enregistrer un commentaire