Press ESC to close

Android SQLite Database – ListView – Filter/Search and CRUD

How to Perform Search and Filter againts SQLite Database. The data is rendered on a ListView. But first we have to insert data to SQLite so we perform basic CRUD to populate the sqlite database. We use SearchView to searc/filter.

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.

We want to search/filter SQLite database using a SearchView.Our component is ListView. First we will insert data to SQLite,then retrieve then filter in realtime as user searches via a SearchView. Lets jump straight in.

Constants.java

The first class is our Constants class which will hold all our SQlite database constants.

DBAdapter.java

Then the DBAdapter class here is responsible for all our CRUD operations including searching.Now for searching we search/filter our data at the server side,at the database level via our SQL statements.

Download

Share Article:

When I was a 2nd year Software Engineering student, I buillt a now defunct online tool called Camposha(from Campus Share) using my then favorite language C#(ASP.NET) to compete OLX in my country(Kenya). The idea was to target campus students in Kenya. I got a few hundred signups but competing OLX proved too daunting. I decided to focus on my studies, learning other languages like Java,Python,Kotlin etc while meanwhile publishing tutorials at my YouTube Channel ProgrammingWizards TV which led to this site(camposha.info). Say hello or post me a suggestion: oclemmi@gmail.com .
Follow me below;
Github
, and on my channel:
ProgrammingWizards TV