Your query should return only 1 column which is a boolean value in the form of 1
(true) or 0
(false) and for this you must use an expression like:
profilePicture IS NOT NULL
You must compare to NULL
with the operator IS
or IS NOT
and not with =
or <>
or !=
:
public boolean checkProfilePicture(String user_id){
SQLiteDatabase MyDB = this.getReadableDatabase();
Cursor cursor = MyDB.rawQuery("SELECT profilePicture IS NOT NULL FROM profiles WHERE ID = ?", new String[] {user_id});
boolean result = cursor.moveToFirst();
if (result) result = (cursor.getInt(0) == 1) ;
cursor.close();
MyDB.close();
return result;
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…