Viewing the db created using Room in Android

My regular little chit chats

Today is Ambedkar Jayanthi. Vishu as well. A festival for which I usually look forward to. This time, it is a quiet Vishu. My husband is working. India is fighting covid 19. My mom prepared a last minute Kani after getting inspired by my friend Dhanya. Mom woke me and Appu for the Kani and dad gave us a “Kaineettam”. No new dresses. The sadya was supposed to be my responsibility. I am backing out. :D The reason being the fact that it was a tiring day yesterday since I took up the Associate Android Developer Certification yesterday and I lost. Adding one more to the stories of my failures in tech!

They say, when we get something for free, we don’t give it the value it deserves. I don’t subscribe to this. But, whenever I see this lady Sreedhanya on the news, I feel bad for not making full use of the Google India Scholarship that I received.

In July 2019, we, the Google India Scholars (2018 batch) had got a free voucher for this certification. Though, the course which I took up(Android Basics Nano Degree) was not sufficient to clear the exam, I decided to take up the certification. The intention was only to get a feel of the exam. Unfortunately, I forgot to make a note of the questions. Since then, Associate Android Developer certification was something which I have been working towards. The course Developing Android Apps from Udacity has been my main reference material since it covered all the 4 components of Android and also, the architectural components like LiveData and View Model.

But, yesterday, I was not able to do it well. I can write the exams only after two months now since I lost in my second attempt also.

Into the blog:

In the new app that I am developing, I am using Room to store data. This experience did help me yesterday, btw. Room is an abstraction over SQLite. One of the difficulties that I faced with Room was to view the saved data. The data is saved on our phone and how do we view this DB?

I kind of spent around 2 days around this. Today I am good with this. I found the answer here on stackoverflow and with little bit of discussions with my better half, who is never happy to help me with tech.

https://github.com/pyarisinghk/SampleCodes/tree/master/RoomWithoutLiveData

The above code on Github demonstrates the creation of tables using Room and viewing the data on a recylcerview on android. As an intermediate step, if we would like to see the data created, what do we do?

When I started using Room, I was confident that I can view the tables using the method followed in one of my earlier blogs on sqlite. However, for some reason, when I tried to list the databases, I could never get the databases listed with this. And, hence this approach.

Step 1 — Download an SQLite Browser application. I downloaded it from here. You might have to go to the downloads tab to download it.

Step 2 — Copy the database created on the mobile on to your machine. There are several ways to do this. I followed this approach using the Android Studio.

View->Tools Windows->Device File Explorer

Opening the device file explorer on Android Studio

The namespace for my app, if you see the code on my Gitub is com.example.android.todolist

package name from the code

Navigate to the below path through the device explorer:

database files on the device file explorer

Click on the databases folder and save all the three files. In my case, it is questionBank, questionBank-shm and questionBank-wal

Step 3: Open DB Browser for SQLite.

Click on Open Database and browse for the questionBank file (without extension) and import the DB into the browser.

DB Browser for SQLite after importing the database.

Click on Browse Database tab and select the table to view the data.

Happy Coding!

I repeat something which I had said earlier. If something has taught me patience, it is not love, it is not motherhood. It is my code, which taught me to be patient. :)

In love with technology and programming. Also a devil’s advocate. Believes in sisterhood. https://pyarisinghk.github.io