I have a requirement for a database with around 400,000 records in iPhone and Android. Any best method in doing this? Is it possible?
-
Sounds like a lot. How about using a web service and an actual database system? – Sune Trudslev Aug 14 '12 at 08:48
-
@ Sune Trudslev : the client specifically want the database to be local.just wondering if actually feasible. – Rowen D Aug 14 '12 at 08:49
-
possible duplicate of [Dealing with a large database in Android](http://stackoverflow.com/questions/4759907/dealing-with-a-large-database-in-android) – halfer Aug 14 '12 at 08:53
-
any idea about this issue in iphone.?? – Rowen D Aug 14 '12 at 09:09
2 Answers
Yes, it is possible.
You can put your database in asset
or raw
folder. Then copy your database at First Run.
You can check if database already exist or not see this answer
see this answer for How to copy large database.
But if you don't have problem with internet access you can develop simple webservice
400,000 records is quite a bit. Even the amount of storage it takes is likely to be quite high, and then there's the problem of running queries on it. Here are a few suggestions to optimize your speed:
If you really need it on the device
- Split the entries into multiple tables alphabetically (or some other way). This way, any queries on records starting with A will only need to be searched for in one fraction of the database, instead of all 400,000 records. This will improve query speed. You may not be able to split data alphabetically, but that was just an example.
If having it on the device is not an option
- Get a high end server which can run queries quickly, and write a small PHP script to interface with it and get your data. This will greatly improve speed, and has the added advantage of not needing to update the app every time your data changes (downloading an app with a database of 400,000 entries every time your data changes will not be appreciated by users)
You could also refer to this article for some more information on dealing with large databases on Android.
Additionally, I read on another SO post that there is a soft limit of 10000 records due to performance. You may or may not be able to get around it.

- 81,899
- 22
- 187
- 195
-
Any problem occurs while downloading this much database to the sd card? – Rowen D Aug 14 '12 at 09:00
-
Your biggest concern would be having the internet connection drop. You could get around it by asking users to download initially on a WiFi, which is less likely to drop, or using a file checksum to validate your download upon completion and redownloading it if there was a problem. – Raghav Sood Aug 14 '12 at 09:02
-
@RaghavSood: my db has more then 9 lakh row and 10-12 collumn, so is it possible to handle in android. – amity Nov 21 '12 at 07:42