0

I have an Android app where I use a SQLIte DataBase. I am using the app and the DB is already big. Now I want to give this app with its DB to my coworkers. Where and How to put the DB for release? I have the DB in my phone but I need it in assets folder. I was trying but it doesn't work. I tried to copy the DB directly however I read that Android compress files in that folder. Please, any solution, thank you in advance.

RobertoFRey
  • 674
  • 1
  • 5
  • 10
  • Have you seen [this](http://stackoverflow.com/a/15025308/1055954) SO answer? You would just need to get the path to your db file and export it to your sd card or anywhere you'd like. – Steve C. Oct 05 '16 at 02:29
  • [This](https://github.com/sanathp/DatabaseManager_For_Android) is another useful tool. You could modify it a bit to export your db to a specified folder/directory – Steve C. Oct 05 '16 at 02:31

3 Answers3

1

http://blog.reigndesign.com/blog/using-your-own-sqlite-database-in-android-applications/

Visit this link. It contains the easiest and well described answer for your question.

Adarsh Sharma
  • 472
  • 2
  • 15
0

You can use emulator Like GenyMotion and any other emulator. Run your app on emulator then just go to Android Studio->Tools->Android Device Monitor Then select the emulator and in the file Explorer you can find your db file . and then export from the device and export to your desktop. here you can give it to any one.

Sardar Khan
  • 845
  • 6
  • 16
0

You can use your own SQLite database by adding it to assets folder. The best way is to use Android SQLiteAssetHelper. Better than reinventing the wheel.

Here the excerpts from its readme:

An Android helper class to manage database creation and version management using an application's raw asset files.

This class provides developers with a simple way to ship their Android app with an existing SQLite database (which may be pre-populated with data) and to manage its initial creation and any upgrades required with subsequent version releases.

It is implemented as an extension to SQLiteOpenHelper, providing an efficient way for ContentProvider implementations to defer opening and upgrading the database until first use.

Rather than implementing the onCreate() and onUpgrade() methods to execute a bunch of SQL statements, developers simply include appropriately named file assets in their project's assets directory. These will include the initial SQLite database file for creation and optionally any SQL upgrade scripts.

ישו אוהב אותך
  • 28,609
  • 11
  • 78
  • 96