Tell me, please, how to change this method? So if there is no element in the table with such a number, false is returned and true otherwise?

public boolean Null(int number) { boolean check=true; SQLiteDatabase db= this.getReadableDatabase(); Cursor cursor = db.query(DATABASE_TABLE, new String[] { COLUMN_ID, COLUMN_BUTTON_NUMBER, COLUMN_BUTTON_WIDTH }, COLUMN_BUTTON_NUMBER + "=?", new String[] { String.valueOf(number) }, null, null, null, null); if (cursor!=null) check=false; return check; } 

    1 answer 1

     if (cursor!=null && cursor.getCount() > 0) { return false; } return true 

    Methods in Java not usually called with a capital (large) letter. In addition, his name doesn’t absolutely reflect what he should do. Name it, for example hasRecord , or contains . You can remove the check variable altogether.