I’m trying to check if the value exists in a column. For example I want to check that column artId contains some numeric value. I’m using following code:
getStar = db.query(TABLE_NAME, new String[] { "artId" },
"artId = " + entryId, null, null,
null, null);
getStar.moveToFirst();
String star = getStar.toString();
Log.w("ID COUNT", star);
if(getStar != null) {
// do something
}
Where entryId is some number.
But I always get something like this:
W/ID COUNT(11303): android.database.sqlite.SQLiteCursor@41aa4c80.
Also I tried to use:
getStar = db.rawQuery("SELECT count(*) FROM "
+ TABLE_NAME + " WHERE artId = '" + entryId + "'", null);
But I got the same result.
So I hope for your help.
The
Cursoris valid (non-null), yes, because it has no errors. Check if it has any data, instead.I’m a bit unsure of the results of the above; instead, you could query the number of results: