Reputation: 41
I'm porting an app I wrote for the phone/ipad to the kindle fire. The app requires a 50 mb sqlite database (16 mb gzipped). This database is a non-issue in IOS; I just add it as a resource and it is transferred with the app. On android, I can't do that because of the size limitations of the items in the assets or resource/raw folders. (What kind of modern os limits file sizes to 1 mb?)
As a work around to get started, I tried copying the db directly to the Fire using the Finder on my mac and the usb connection. I can see the file on the Fire in the finder but I can't access it via code in the path from getFilesDir(); File.exists() returns false. I also looked in the external files area but the getExternalFilesDir() method returns null on the Fire. (I've declared the WRITE_EXTERNAL_STORAGE permission.)
If I actually completely the port, I'll probably have to either 1) split the db into 17 pieces each under 1 mb, or 2) force a download at install time. Neither is very appetizing.
Anyone have any advice on how to make the manual copy work so I can get started? In addition, is there any alternative to the split/download issue? It seems ridiculous to have to wrestle with this issue.
Upvotes: 0
Views: 253
Reputation: 1007349
On android, I can't do that because of the size limitations of the items in the assets or resource/raw folders. (What kind of modern os limits file sizes to 1 mb?)
Sure you can. You have to give it a file extension that won't be compressed, possibly simply by compressing it yourself and storing it as a .zip
file. SQLiteAssetHelper
does just that for pre-packaging a database with your app.
If I actually completely the port, I'll probably have to either 1) split the db into 17 pieces each under 1 mb, or 2) force a download at install time. Neither is very appetizing.
Or, you could use the aforementioned SQLiteAssetHelper
or techniques based upon it.
In addition, is there any alternative to the split/download issue?
See above.
I can see the file on the Fire in the finder but I can't access it via code in the path from getFilesDir(); File.exists() returns false.
SQLite databases typically go into getDatabaseDir()
, not getFilesDir()
.
I also looked in the external files area but the getExternalFilesDir() method returns null on the Fire.
If you have the Kindle Fire's external storage mounted as a volume in your OS X environment, that storage is not available to your Android app, due to limitations in the USB Mass Storage spec. Since the Fire still runs Android 2.3, it's still using mass storage mode -- most other Android tablets are on Android 3.0+, where they switched away from mass storage mode to overcome this particular limitation.
If you are getting null
even when the device is unmounted as a volume, that would be odd.
Upvotes: 2