Android Jetpack: Room

Android Developers · 85K views · 2018 · 5:32

Open on YouTube

Software (other)Databases & storageexplainerdated

Why Stack Overflow recommends it

Stack Overflow users link it when answering Android beginners who are struggling with raw SQLite and need a quick, official overview of Room as the safer alternative.

Recommended by 2 people across 3 different months, 2019 to 2020.

What it is

A 5.5-minute introduction to Room, the Jetpack database persistence library for Android, presented by Florina Muntenescu of the Android Developers channel. It covers how Room cuts boilerplate, maps query results to objects, checks queries at compile time, and keeps database work off the main thread.

What people said

Recommends MD Naseem Ashraf · 2019-03 · Stack Overflow · on “Question about saving and loading objects in Android”

You should save your data into the on-device SQLite database instead of JSON. Look into Room Persistence Library for a much smoother way of saving your objects in SQLite. Room Persistence Library Documentation [LINK] Google Android Developer Video on Youtube. [this video] You can follow the linked examples, sample and Google Codelab [LINK] to learn it quickly. It's fairly easy. Or, you can go the not so recommended way of using SQLite directly - Read here [LINK] .

Recommends MD Naseem Ashraf · 2019-03 · Stack Overflow · on “When I try onCreate the CREATE_USER_TABLE got error”

Have you looked into Room android architecture component? Here's a link to Room: [LINK] This Room persistence library is built on SQLite and makes it very easy to turn your classes into tables for SQLite. It can also generate a lot of needed SQL instructions on your behalf making it easy and error free. Give it a try. Here's the official video on it: [this video]

Recommends MD Naseem Ashraf · 2019-03 · Stack Overflow · on “What is the error in this cursor created for database?”

Also, as a really better alternative to directly using SQLite, try Room Persistence Library by Google (introduced in 2017) instead. Read here: [LINK] and watch this for a quick idea: [this video] Room reduces all SQLite boilerplate code and any possibility of bugs, by generating it automatically for you. You can directly map your data object classes with the database.

Recommends MD Naseem Ashraf · 2019-03 · Stack Overflow · on “Using Android studio and my application force closes when i click a button”

I would suggest you look into Room Persistence Library by Google, which is the newly introduced and better way to interact with your SQLite DB. Look here: [this video]

Recommends MD Naseem Ashraf · 2019-03 · Stack Overflow · on “How to to insert and retrieve data in SQLite?”

You should use Room Persistence Library which is an ORM wrapper over SQLite instead of directly using SQLite. See this: [this video] and read this: [LINK] It is less error prone and easier to use. Also read here: [LINK]

Recommends MD Naseem Ashraf · 2019-04 · Stack Overflow · on “How to display single SQLite data into textview?”

If you're new to SQLite and Android, you might want to try the newer, easier and better Room Persistence Library [LINK] . Here's the official video [this video] about it. Also, add logcat error file in your question whenever you have issues with Android.

Recommends MD Naseem Ashraf · 2019-04 · Stack Overflow · on “Kotlin/Android: android.database.sqlite.SQLiteException: no such table: Table_xx (code 1 SQLITE_ERROR): , while compiling: select * from Table_xx”

Please include your logcat output in the question. If you're new to SQL or SQLite, I'd suggest you look into Room Persistence Library [LINK] , which is safer, less error-prone and easier to use. Android Developer video about it here [this video] .

Recommends MD Naseem Ashraf · 2019-04 · Stack Overflow · on “Data no longer saves to table in my SQLite DB”

Have you logged and seen if your Database helper class works as intended. Especially, the onCreate method. Also, try changing the Database version and running your code. I'd suggest you look into Room Persistence Library [LINK] , it is recommended by Google [LINK] and is safer (less error prone) and easier to use than SQLite directly. See this [this video] youtube on Room by Android Developer channel.

Recommends Domino · 2020-06 · Stack Overflow · on “Synchronize RecyclerView data between two devices?”

The thing you are looking for is LiveData. There are really nice tutorials from Android Jetpack team: How to connect Room with RxJava (e.g. LiveData): [this video] LiveData explained: [LINK] Code examples: [LINK]

Cites glisu · 2019-02 · Stack Overflow · on “How to store chat history in Sqlite at runtime like whatsapp in Android?”

The preferred and much easier way in android is to use Room library [this video] , which greatly reduces boilerplate and works smoothly with other architechture components like LiveData [LINK] , handles background queries for you and provides compile time checks just for a few lines of code.