-1

I'm new to android development. I'm trying to make a "Did you know?" android apps. My problem is that how can I store with over 1,000 facts using SQLite database.

Do I need to need to insert every fact one by one?

Juan Cortés
  • 20,634
  • 8
  • 68
  • 91
Sparcsky
  • 377
  • 3
  • 15
  • Or you can use a CSV file and import it. Or just use a prefilled database. But someone has to feed it with data anyway. – Phantômaxx Dec 10 '15 at 15:04
  • 2
    Well, if you're moving between houses/apartments, and have 1000 boxes, how are you going to get the boxes into the new location? – Marc B Dec 10 '15 at 15:05
  • See [How to ship an Android application with a database?](http://stackoverflow.com/questions/513084/how-to-ship-an-android-application-with-a-database) – CL. Dec 10 '15 at 19:33

1 Answers1

1

Step #1: Create the database, with the data, on your development machine.

Step #2: Put that database in assets/.

Step #3: Use SQLiteAssetHelper to unpack that database and use it from within your app.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • in step #1: What database should I be using?? – Sparcsky Dec 10 '15 at 18:07
  • Can I use SQLite browser? – Sparcsky Dec 11 '15 at 02:09
  • @IanJasper: Any SQLite client should work, if you want to build the database manually. Or, there are SQLite bindings for many programming languages, if you wanted to built it using some scripting tools. For example, [my book](https://commonsware.com/Android) uses SQLite's FTS3 for offering full-text search. As part of building the APK edition of my book, I use Ruby to create the SQLite database with the FTS3 table, which I package with the APK using the approach outlined in my answer. – CommonsWare Dec 11 '15 at 12:40