我在SQLite中有一个只包含一个条目的表 - 我的数据库的版本号。 目前正在使用DB Browser for SQLite我可以看到该表有一行。
但是当我运行以下代码时,它显示cursor.getCount()为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;
}