Continuing from previous weeks, you might have observed that the values generated and changes made by users are not saved. This week, you will be adding persistant storage to your app.
Follow the instructions below to complete your app.
SQLiteOpenHelper
. This class will create a new database upon initialization. There is a Use
r table, whose structure follows the User
class diagram. 20 User
data are generated and inserted into the table. The name
, description
and value of followed
are randomized, the value of id
is an auto-increment primary key.Create a getUsers()
function in your db handler. This function will returns all the user information from the database as a List.
Modify your RecyclerView
so that it is pre-populated with information from the database only.
Create a updateUser()
function in your db handler. This function will receive a User
object and update the corresponding value in the database.
Modify your MainActivity
so that it calls this function to update the database every time the Follow/Unfollow button is clicked.
If all the above have been modified successfully, changes made to the user profile will be saved persistently. Test your app to verify this behaviour.
Remove the intent-filter
for the MainActivity
from the manifest
. This will allow the user to launch your app via the ListActivity
only.