Tuesday, January 28, 2014
How to Use PrePopulated SQLite Database in Android
Manchu Bhargavi
6:17 AM
android
,
exixting databse in android
,
per-populated database
,
sqlite
,
sqlite db in android
,
sqlitedb
2 comments
:
Here we can create SQLite database is created at runtime. we can use this an existing database in Android App
Creating the Pre-Populated Database :
To create a Separate database using SQLite Database Browser we can download the SQLManager
addon on Firefox
Using this SQLite Manager create a sample.sqlite3 file with one table called friends. which shows list of friends and has two fields: id and name
To make your database work correctly on a device you have to included two modifications.
1. Rename the id field of your own table to "_id" you can done this with modify the table and then choosing the necessary table and field names.
2. Add the android_metadata table.To do that open the Execute SQL tab and run this both command
into the SQL String field:
CREATE TABLE android_metadata (locale_TEXT);
INSERT INTO android_metadata VALUES ('en_US');
click the execute query button and now you can export the database and located in assests folder in Android Project.
Implementing the ExternalDbOpenHelper class
This class is inherited from SOLiteOpenHelper. The application database are stored in the data/data/<name of your package>/databases/ folder on your device.
Note: Export the database from SQLManager and put in assests folder in Android Project.
Creating the Pre-Populated Database :
To create a Separate database using SQLite Database Browser we can download the SQLManager
addon on Firefox
Using this SQLite Manager create a sample.sqlite3 file with one table called friends. which shows list of friends and has two fields: id and name
To make your database work correctly on a device you have to included two modifications.
1. Rename the id field of your own table to "_id" you can done this with modify the table and then choosing the necessary table and field names.
2. Add the android_metadata table.To do that open the Execute SQL tab and run this both command
into the SQL String field:
CREATE TABLE android_metadata (locale_TEXT);
INSERT INTO android_metadata VALUES ('en_US');
click the execute query button and now you can export the database and located in assests folder in Android Project.
Implementing the ExternalDbOpenHelper class
This class is inherited from SOLiteOpenHelper. The application database are stored in the data/data/<name of your package>/databases/ folder on your device.
Note: Export the database from SQLManager and put in assests folder in Android Project.
Download this Project
Subscribe to:
Post Comments
(
Atom
)
Hi Manchu Bhargavi
ReplyDeleteCan you please do this with a cutom listview that has multiple column, same as this project but with multiple column.
Thank you
c++ codings by examples
ReplyDelete