Android SQLite ListView

Android SQLite ListView Tutorials and Examples.

Top Android SQLite ListView Examples

Let's look at some examples.

  • Android Swipe Tabbed SQLite - Fragments With ListView tutorial.*

  • First we insert data into SQLite database from a material dialog.
  • Then we select according to a given category.
  • The category depends on the tab.
  • Each fragment consist of a ListView.
  • Each ListView has data from a given category.
  • The fragments are swipeable and the tabs are clickeable as well.

Nowadays most apps need or require to store content or data in some form.

There is the cloud but it isn’t a replacement for local storage.Neither will it be in the near future.Storing data locally is important because its easily retrievable,doesn’t require internet connection and is fast. Good old SQLite is still the way to go.

Together with Realm database,they are two ways that are now common in data storage.The package we shall be using is android.database.sqlite It Was added in API 1 and contains classes which your app can use when talking to and managing your database. Android does ship with SQLite database. As of now SQLite 3.4.0. One of those classes is

Android.database.sqlite.SQliteDatabase This class derives from android.database.SQLite.SQLiteCloseable and obviously,java.lang.Object. This class has methods that we can use to basically, manage our SQLite database. It has methods for CRUD stuff. Also execute SQL statements.

A database has to be unique for each single application, within that application. Now today we look at ListView and SQLite database.The two are normally commonly used so we try to leave no stone untouched.Nevertheless we have covered full CRUD operations previously but with RecyclerView.Today we look at with ListView.

In short this is what we do here:

  1. INSERT/SAVE to SQLite database.
  2. SELECT/RETRIEVE data to ListView.
  3. UPDATE/EDIT data and refresh.
  4. DELETE/REMOVE data on ContextMenu Item selected.
  5. We are using Context Menu,material EditTexts and ListView with cards.

In today's tutorial,we cover how to filter/search data from SQLite database.As we always do here at ProgrammingWizards,we start from scratch.So we first create our table programmatically,Insert data,select that data from database while applying a search.We are performing a server side filter if you like,at the database level. In short this is what we do :

  • INSERT data to our SQlite database table.
  • SELECT while performing a dynamic filter,using a searchterm specified in our SearchView.
  • Handle ItemClicks of filtered items.

Now people we discuss Android SQLite database and Internet images .Our purpose is simple : get image urls from the web and maybe some text,save them in SQlite database,Load the images from the internet,of course URLs from SQlite database. Basically this is what we do here :

  1. Download Images From the Web,in an image hosting site in my case, or anywhere for you.
  2. Save the image URLs and some text that we type in beautiful Material EditTexts. 3. Save these to our database : name and image url.Our SQLite database.
  3. Retrieve them from our database,our name and image url.
  4. Show them in our custom ListView: images and text. 6.We use the nice Picasso library to download and cache images automatically,both in memory and disk.  

In this class we see how to perform Next/Previous type of pagination with SQLite data with ListView as our adapterview.The user can add data dynamically with an input dialog and the padination will still work.If you are in the first page,the previous button is disabled while if you are in the last page the next button is enabled.

This is an android tutorial of how to work with SQLite datbase and RecyclerView with ContextMenu.

We perform the following:

  1. Insert Data to SQLite Database
  2. Retrieve Data from SQLite Database and render in a RecyclerView
  3. Long press the recyclerview to show a contextmenu.
  4. Choose Delete to Delete data from SQLite database.

Many a times you need to filter or serahc data. That data may be contained in an SQLite database.

There are two ways to do that:

  • Clientside Search/Filter - Retrieving everything from database,populating arraylist, then searching the arraylist.
  • Serverside Search/Filter - Applying search/filter at the database level and returning only data matching the search term.

The second option is the faster one since we take advantage of the heavily optimized SQL databases.

We use the second approach in this tutorial.

But first we need to insert data into database and populate the ListView. So we do all those.

We use the SearchView as our search input widget.

Let's go.

Best Regards, Oclemy.

How do You Feel after reading this?

According to scientists, we humans have 8 primary innate emotions: joy, acceptance, fear, surprise, sadness, disgust, anger, and anticipation. Feel free to tell us how you feel about this article using these emotes or via the comment section. This feedback helps us gauge our progress.

Help me Grow.

I set myself some growth ambitions I desire to achieve by this year's end regarding this website and my youtube channel. Am halfway. Help me reach them by:


What do You Think

Previous Post Next Post