Created
May 7, 2020 08:56
-
-
Save ruslan-hut/389134bc0bd3cbbbc783c41f430b00ff to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private boolean tableExists(SQLiteDatabase sqLiteDatabase, String table){ | |
if (sqLiteDatabase == null || !sqLiteDatabase.isOpen() || table == null){ | |
return false; | |
} | |
int count = 0; | |
String[] args = {"table",table}; | |
Cursor cursor = sqLiteDatabase.rawQuery("SELECT COUNT(*) FROM sqlite_master WHERE type=? AND name=?",args,null); | |
if (cursor.moveToFirst()){ | |
count = cursor.getInt(0); | |
} | |
cursor.close(); | |
return count > 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
nice