Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ruslan-hut/389134bc0bd3cbbbc783c41f430b00ff to your computer and use it in GitHub Desktop.
Save ruslan-hut/389134bc0bd3cbbbc783c41f430b00ff to your computer and use it in GitHub Desktop.
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;
}
@nguyen15970
Copy link

nice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment