RecyclerView with sqlite database android tutorial

The following gif is an overview of what we are about to build
add, edit, delete, search contacts

First of all create a new project in android studio
now setup the following dependencies in your app level build.gradle file

implementation '' 
implementation '' 
implementation '' 
implementation ''

Now setup all the assets like shown below

go to res >> drawable and create brown_border.xml,pedit.png,pdelete.png




Now go to res >> values >> colors.xml and add the following

Now go to res >> values >> strings.xml and add the following

Now create res >> menu >> menu_main.xml like this

Now create res >> layout and add the following

activity_main.xml add_contact_layout.xml contact_list_layout.xml
Now let us look into some java code
First of all create a helper class which extends SQLiteOpenHelper as shown below
The above helper class provides methods to perform all the basic CRUD operations like add, update, delete etc.Now we should create a model class for the contacts object, it should be like
Now we should create a recyclerview adapter for our recyclerview. It will include a Filter method which would be used to do search operations within our contacts list.

Below is the code for which is used in the above adapter class
Update your file like shown below
With this, we have come to the end of this tutorial, now try running the app!

No comments:

Post a Comment