SQLite View All Records from Table

viewing-records-in-sqlite-android-thumb

To start with this tutorial we you first need to complete this tutorial in which we have created a database and table, and Inserted the values into our tables.

SQLite Insert Record into Table

In this tutorial we will be retrieving values from our table and displaying on Listview

Step 1:

To display records in ListView we first need to create a custom row through which every record from table would be inflated onto listview.

Goto Layout folder, Right click and add new layout resource file and name it row.xml

paste the code below into it

 

Step 2:

Get into your MainActivity.java File and this time we need to create an Adapter using which we can set values to our ListView.  Add the ViewAdapter below the onCreate() method.

Step 3:

Now on the click on retrieve button insert the code below.

Step 4:

Now in DBhandler file create a new method  named getAllContacts()

Step 5:

Final MainActivity.java file and DBHandler file will look like this

 

One thought on “SQLite View All Records from Table

Leave a Reply

Your email address will not be published. Required fields are marked *