0

I need to ship an app that uses read-only access to several preexisting SQLite3 DB's that each are a couple of 100MB's, total combines size > 1GB. The databases are created on a Mac, and are currently used in a shipping iOS app. I am pretty proficient in Java, but new to Android.

This leads to the following questions:

1) Will I need to modify the databases? I only plan to use them with SQLiteDatabase::rawQuery queries, so no nee for bindings and metadata I hope.

2) It it really correct that even if the DB's will only be used as read-only, I'll have to copy them out of the app bundle or download them to user directory on first start-up?

3) The queries can be slow. I want to run them in a thread and provide data via a callback. Is this done the way it's done in normal Java (Runnable/Thread), or will I have to use another method?

4) Is there anything else that's obvious to the Androidan that I have clearly missed?

  • 1
    Are you *absolutely sure* that packing the whole database into the app is the best way to do this? Is every user likely to need every part of the database in the app or might you be better off hosting the majority of the data on a server somewhere or out on the cloud and only cacheing a part of it on each user's phone? By requiring that much space you are certainly applying strong restrictions to the number of potential users for your app. – glenatron Jun 06 '12 at 13:27
  • you should reevaluate your application's design – waqaslam Jun 06 '12 at 13:30
  • That's not possible. The whole point of the application is to access the huge database to help it interpret what the user is trying to type. Response time and a huge vocabulary is absolutely necessary for the use case. The users will be schools or assistive technology helpers with little or no IT skills, and they will want a fire-and-forget installation. Downloading essential parts of the app later will not appeal to them. – Anders Sewerin Johansen Jun 06 '12 at 13:36

2 Answers2

1

for a decent example of a sqlite helper class look here

  1. you shouldnt need to edit the database. my sqlite databases work the same wether I access them via sqlite3 or with the android my sqlite helper class

  2. once you copy them you can read and write

  3. not really sure about this answer. i will say though that the database helper class above seems to work just fine (fast) but my db is smaller (500kb)

  4. dont think so

Community
  • 1
  • 1
owen gerig
  • 6,165
  • 6
  • 52
  • 91
  • Re 2: I want to avoid copying the DB's. They are HUGE, and copying them will eat up double the storage. Copying them isn't required in iOS, so I hoped it was doable in Android. Re 3: The queries are inherently slow. There's a lot of data, and the queries involve sorting and selecting the N top ranked results that match other criteria. Trust me: They can not be optimized to fix this. A query time of > .5 seconds can and will happen every once in a while. – Anders Sewerin Johansen Jun 06 '12 at 13:39
  • copy then delete, although i havnt done the delete part i believe its possible. regardless the data will be local so as long as there is only one copy there isnt much difference. – owen gerig Jun 06 '12 at 13:41
  • unless you are going to host this data the installing of your app will be slow, from downloading all the data to doing the install, the extra time of copping is just part of that. – owen gerig Jun 06 '12 at 13:43
1

1) No, it should work fine.

2) Yes, if you want to ship an APK that is over 50Mb you will need to use an expansion file.

3) For easy background tasks with a call back you could use an ASyncTask.

swiftBoy
  • 35,607
  • 26
  • 136
  • 135
Dazzy_G
  • 820
  • 9
  • 22