Skip to content

Instantly share code, notes, and snippets.

@izmajlowiczl
Created April 27, 2017 07:15
Show Gist options
  • Save izmajlowiczl/3b5977264de2de5f5b029b31b04df29f to your computer and use it in GitHub Desktop.
Save izmajlowiczl/3b5977264de2de5f5b029b31b04df29f to your computer and use it in GitHub Desktop.
fun SQLiteDatabase.doesTableExistIncludingTemps(tableName: String): Boolean {
val sql = """SELECT name
FROM (SELECT * FROM sqlite_master UNION ALL SELECT * FROM sqlite_temp_master)
WHERE type='table';"""
val c = rawQuery(sql, null)
while (c.moveToNext()) {
if (c.getString(0) == tableName) return true else continue
}
return false
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment