buildbad.blogg.se

Kotlin sqlite
Kotlin sqlite






kotlin sqlite

You can see all the operations in Anko documentation. You can also apply all regular database operations such as limit, orderBy, having or groupBy. Personally in this case I find the second option simpler.

kotlin sqlite

All of them must be String in this case: select("Person") If you use this class, which extends SQLiteOpenHelper, you can create blocks of code where you will execute the database operations, as follows: e )",Īnd there is another, more similar to that used in the Android framework, which allows to include interrogation sign and values more later.

kotlin sqlite

Anko does this for you.įor this you need to include SQLite dependency for Anko: compile ':anko-sqlite:0.10.0' You’ll then need to remember to close after the requests. On Android, you’ll need a SQLiteOpenHelper, which you use to retrieve the database. You’ll see here how to create your database from scratch. With Anko, however, we can continue to work as low-level as when we use the framework, but get rid of some of the more tedious parts of its implementation. Truth to be told: writing databases in Android is quite boring.Īll the boilerplate required to work with SQLite is far from being the most delightful thing in the world.įortunately, there are already enough libraries that simplify this task, one of them announced during the latest Google I/O, called Room.








Kotlin sqlite