Skip to content

Instantly share code, notes, and snippets.

@nguyenlinhnttu
Created December 29, 2017 10:18
Show Gist options
  • Save nguyenlinhnttu/44df545584f2ed7d09cdf1933788ef42 to your computer and use it in GitHub Desktop.
Save nguyenlinhnttu/44df545584f2ed7d09cdf1933788ef42 to your computer and use it in GitHub Desktop.
Sample Query SQLite Kotlin
fun getListCat(): ArrayList<ItemMenu> {
var query = "SELECT * FROM " + CATEGORY
var cursor :Cursor = database.rawQuery(query, null)
var arrCategory = ArrayList<ItemMenu>()
if (cursor.moveToFirst()) {
do {
var item = ItemMenu(cursor.getString(0), cursor.getString(1))
arrCategory.add(item)
} while (cursor.moveToNext())
}
cursor.close()
return arrCategory
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment