Hello Everyone!
Today, I will show you how to check the SQLite Database.
Last week, I created a tutorial of how to do a registration page and storing data into SQLite Database. In today’s tutorial, I will show you how to check that data.
First things first! Download DB Browser for SQLite and install it into your computer. We will be using DB Browser for SQLite to view .db files.

Now go onto Android Studio and go to Tools > Android > Android Device Monitor to open up . I couldn’t get it to open from Android Device Monitor, so I did a manual open instead. What we want is the “monitor” application in the folder Users > AppData > Local > Android > sdk > tools > lib > monitor-x86, mine is an x86 machine, so I had to do this.
Regardless you should see the Android Device Monitor popup like below:

Click on your virtual device and navigate down to data > data > [package name] > data > User.db that you created, and then on the top right, click “Pull a file from the device” and save it anywhere.

Next open up DB Browser for SQLite, Click File > open database and select the User.db file. Then click the “Browse Database” tab, and then select the User.db file. It should have the following information:

Great!!! Now we know for sure that the data is being inserted into the database! Now we can easily query the information and set these information to some TextViews.
Let’s continue from the last tutorial for simplicity. We left off at defining “NextActivity” so now let’s use NextActivity to display the data we stored after registering. Go to the activity_next.xml in the layout folder. Let’s use TextViews to display the data stored from earlier, and a button to click on to display the data. Give each their respective IDs, and define it in the java file.

And set each TextView and Button to their id’s in the java file. when the button Display Data is clicked, we will call the function displayData()
Now that we have set up what the activity will do (display the data stored from the registration activity), let’s go ahead and define the displayData() function. Go back to the DatabaseHelper.java file and create a new function called getAllData() which will get all the data on the database. We will define what this query is with the following code:

We define an SQLiteDatabase instance and set it to the built-in getWritableDatabase(). Then we define a Cursor instance (Cursor being the pointer to the read-write information of the database) and set it to what we want to query. We want all the information on the database, so we’ll use SELECT * FROM user_table which means to select all from the user database table.
If we want a more direct and specific query, for example, querying a specific user such as myself and my phone number, then we can do SELECT FirstName, Phone FROM user_table WHERE FirstName=”Matthew”. This will display only the matching first name “Matthew” and Matthew’s phone number.
Now all we have to do is call getAllData() in the displayData() function of NextActivity.

And that’s it!! Let’s test it on the Emulator.

AWESOME! The data is displayed as it should be, and we have successfully queried the data from SQLite Database!

That’s it for now! Stay tune as my next tutorial will be on how to update / add / delete information from the database.
Thanks! and Happy Coding!
Below is the code:












