Enter some dummy data:
The very first thing you need to do when you want to use SQLite is create a sub class of SQLiteOpenHelper.
Create some constants for database name, table name, and the database path:
Note that ice.tea09.splitedemo is your project namespace.
Implement constructor, and some methods of super class:
Method checkDatabase() allow you to check if the database exists on the phone or not:
Method copyDatabase() used to copy SQLite file in assets folder to data folder of application on the phone:
Finally, createDatabase() method - which will be called every time we launch app. It will check if the database does not exist on the phone, It’ll copy the database to data folder of application:
Finally, method that help you retrieve data from database:
The way we using DatabaseHelper in MainActivity:
This post is licensed under CC BY 4.0
by the author.