samedi 24 janvier 2015

check if the data already exists in the sqlite database

I am getting objectId of a row from parse. The same objectId I have saved in the sqlite databse for that corresponding object whille sending it to parse.



String objectId = archiveNotes.getObjectId();


And, then I am looking if the row with the same objectId exists in the database :



tasks_Database_Operations tasksDatabaseOperations = new tasks_Database_Operations(getApplicationContext());

SQLiteDatabase database = tasksDatabaseOperations.getReadableDatabase();
Log.d("HirakDebug", "Got readable database");
String tablename = tasks_Database_Operations.ASSIS_NOTES_TABLE_NAME;
String where = tasks_Database_Operations.ASSIS_NOTES_PARSE_OBJECT_ID + "=?";
String[] whereArgs = new String[]{objectId};
Cursor cursor = database.query(tablename, null, where, whereArgs, null, null, null);

if (cursor.moveToFirst()){
Log.d("HirakDebug", "SQHelper PArse sync data exist");

} else {
Log.d("HirakDebug", "SQHelper PArse sync data doesnt exist");
tasksDatabaseOperations.putFromParse(objectId, archived, color, date, locked, note, title);
Log.d("HirakDebug", "Got from parse " + objectId + " " + archived + " " +
color + " " + date + " " + locked + " " + note + " " + title);
}


But, I am not seeing either of the Logs from if...else statemenet in my logcat. That means none of them are executed. Neither I am getting any error.


Can anyone please findout where i am doing a mistake?


Aucun commentaire:

Enregistrer un commentaire