I want to show an alertbox if the table does not exist or the table content is empty.
To check if the table is empty I'm using:
cCheckDB = db.rawQuery("SELECT COUNT(*) FROM " + MainActivity.TABLE_NAME +"", null);
if (cCheckDB != null) {
cCheckDB.moveToFirst();
if (cCheckDB.getInt (0) == 0) {
// EMPTY
}
}
But how to wrap this in an "if table exist"? What is the best way?
I know both ways to check if a table exist or to check if there is content in it. But I want to use the checks in a meaningful and way and not in single query if this is possible - that's my question.