How to manage big data on android app? - android

I have a big database that I use on my website and I would like to use it for an android application without an Internet connection.
My database can export to .db file. How should I do to use this file for my android app.
Regards

Keep copy of your database in asset folder,
copy that database in /data/data/your.package.name/databases while you loading your application first time.
if your database is larger than 1MB Divide the database in small parts.
ex: if size = 8 MB make 8 parts of 1MB than join that parts problematically while copying.

Related

SQLiteAssetHelper database file size

I have an app that includes a pre-populated sqlite database, encoded in UTF-8. DB file size is 170 MB. I am using SQLiteAssetHelper to manage the database
Considering most Android Apps are less than 50MB, it is quite large. My current app size according to the Settings is 238MB.
Is there any way to make the downloadable app size smaller when user downloads it from Store? I have read that you can zip the sqlite database, but I haven't tried that yet. Will that make the app's download size smaller? Are there any other better options?
I am concerned about the app's download size, not the storage space. I do need the app to work offline, so web service is not an option.
Is there any way to make the downloadable app size smaller when user downloads it from Store?
Have a smaller database.
Will that make the app's download size smaller?
Since the APK is already a ZIP file, no, as ZIPping an entry in a ZIP file will not reduce its size further.
Are there any other better options?
You could not use SQLiteAssetHelper, and download the database on the first run of your app. Or, you could not use SQLiteAssetHelper and look into using APK expansion files. Neither of those will change the number of bytes to be downloaded, but they will reduce the overall disk space your app takes up a bit. You can use tools like command-line unzip to see how much space your database file is taking up in the APK (my one test app's database is 89% compressed and so takes up 568 bytes instead of the uncompressed 5120 bytes). This space is non-recoverable, insofar as you have no way of deleting a database from assets/. Assuming a similar compression ratio, your 170MB database will take up an extra ~17MB on disk from the copy in assets/.
You could also not have the 170MB database on the device at all, and have your app work with some Web service to access a hosted copy of the database. This won't work offline, of course.
I ended up using text files for the major lookup tables in my database. I added them in the assets folder, along with the smaller sqlite db. I kept only the small tables that I needed to do inserts/adds in the sqlite db.
And I was also able to easily encrypt the data in the file (which is not easy to do in sqlite)
I had to create indexes to index the file data, and used binary search to find by key or value.
That shortened the apk size, and it's about 30 MB now. Before it was about 76MB. and the app size was > 200 MB.

30mb Sqlite3 Database - Including in android app

I have an SQLite3 Database (created in a desktop sqlite application), with the android_metadata table for use in my android application.
What is the best way to create the android database using this database file?
I have tried including it in the assets folder, but got a size error when copying this to the application and wasn't sure if this was due to the asset files having a maximum size.
I have also read guides on storing the database on the sd card and accessing it.
Which function on androids sqlite helper is best to open a new database from an sqlite3 export?
I pushed the database file to data/data/com../databases/ and it created an "android.database.sqlite.SQLiteDatabaseCorruptException: disk malformed..
Not sure how to do this, appreciate any help!
You can attempt to use SQLiteAssetHelper for this, as it is designed to make it easy for developers to package a database with their app.
That being said, your database is much too big. There are plenty of 1.6 devices that will not have room for both your APK and the unpacked database.
The reason you get a size error is because android likes to compress files in the Assets folder but then can't decompress them if they are over 1 meg in size. Some file extensions do not get compressed like jpeg, gif, mp3, jet. I always name my db something like name.db.jet and then rename it to name.db when I copy it to the Database directory. The extension on the file really means nothing but naming it with an extension like .jet gets around the max size restrictions.
By the way, if you are going to include a DB that is 30mb in size, be sure to include it compressed. That will take it down to about 10mb in size.

Can I store multiple databases in an application's database folder?

I was having an SQLite database with size less than 1 MB in the asset folder. I am copying this database to the applications default database folder on application launch. It was working fine. Now the database has grown and due to limitations with the Asset folder, I am not able to copy the database from Asset folder to the application.
Is there any way to manage multiple databases in application? If yes, what will be the methods to query them separately? Please share some good link for such database queries.
Change your db file's suffix to media file type, such like yourdb.mpg . then you won't be limited by 1mb size, and you can copy it to data/your.packge/database folder when your app first run.

How to use large database (Sqlite more than 100 MB) in android application?

i develop one application in which require sqlite database. Database size is very large approx. 100 Mb.
so i have not any idea which way use these database in my application.
database is some private contents so not installed in sdcard...
Can android app support or store 100MB database in data directory ?
If app store database in sdcard then , any other way to implement so user can not see or used these database ?
How to encode my sqlite database and store in device so user can not used these database ?
Please anyone suggest me if any idea related to large database.
I think u can store the database file in the data directory. There is no such restriction on the size of file in Android I suppose. At least I have never read about any such restriction.

Using sqlite db created in Windows but to be accessed in Android

I already have a sqlite3 db file that I created in Windows, is there a way to package this file into my android application and access it as a sqlite db from within the application or do I have to create a db on application load or something in Android only?
The db has about a thousand records, so writing sql scripts again might be monotonous and cumbersome.
Got this link, seems to serve my purpose
Package it as an asset or raw resource. Copy it out from there onto the appropriate spot on the device. Downside: You will take up 1.5x to 2x the space on the flash (for the possibly-compressed copy stored in the APK plus the actual to-be-used copy).
Or, download the database from a server on first run.

Categories

Resources