1

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!

user1184075
  • 13
  • 1
  • 3

2 Answers2

0

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.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
0

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.

JustinMorris
  • 7,259
  • 3
  • 30
  • 36