I have a table in SQLite that hold only one entry - the version number of my database. currently using DB Browser for SQLite I can see that the table has one row.
but when I run the following code, it shows that cursor.getCount() is 0 WHY??
private boolean checkVersion(DBmanipulation currentDB) {
//returning value
boolean newerVersionExist = false;
//Get SQLiteVersion
String currentQuery = "SELECT " + KEY_VERSION + " FROM " + TABLE_VERSION;
Cursor cursor = getReadableDatabase().rawQuery(currentQuery, null);
if (cursor != null && cursor.getCount() > 0) {
cursor.moveToFirst();
//there is something in the table
//Check if the current version is older
int currentVersion = cursor.getInt(cursor.getColumnIndex("version_number"));
System.out.println("RESULTzz Current version is:" + currentVersion);
int remoteVersion = currentDB.getVersionNumber();
System.out.println("RESULTzz Remote version is:" + remoteVersion);
if (remoteVersion > currentVersion) {
newerVersionExist = true;
}
return newerVersionExist;
}
Aucun commentaire:
Enregistrer un commentaire