4

Say I have data about customers and I initially have around 1000 pre-determined customers details I want to insert into my SQLiteDatabase.

Would it be wise to store that data into a text file in my assets folder with my own formatting (tabs to indicate columns and new lines to indicate rows), then just read the text file and insert the data into the database with insert statements? I feel this is not the best way and very in-efficient.

Is there a better way of doing this?

slim1801
  • 531
  • 3
  • 8
  • 19

4 Answers4

1

You can use the utility to create your SQL Lite database offline on PC, such as this:

http://portableapps.com/apps/development/sqlite_database_browser_portable

You can package this database along with your app and then put it on phone storage and continue from there.

Madhur Ahuja
  • 22,211
  • 14
  • 71
  • 124
1

User a .sqlite or .db file in your assets folder with prelaoded entries and import this file to you app from asset folder.

You can use this add-on to access and create you db file

https://addons.mozilla.org/en-US/firefox/addon/sqlite-manager/

and this is tutorial to access database file from assets

Android: Accessing assets folder sqlite database file with .sqlite extension

Community
  • 1
  • 1
Vaibhav Agarwal
  • 4,499
  • 3
  • 19
  • 20
1

You can do do in two ways..

Way 1:

You can make one .sqlite file with already 1000 customer records inserted in database and you can use it that .sqlite file from assets folder. Then you can copy those records in your internal database or use that only database.

Way 2:

You can put this 1000 records on server and call it by web service at first time app is launched..

Hope it will help you.

Rushabh Patel
  • 3,052
  • 4
  • 26
  • 58
0

I would bring along the already pre-populated database .db file.

I've done this before with "sample" data included as part of an application.

Jonathon Reinhart
  • 132,704
  • 33
  • 254
  • 328