0

I have created an SQLite database by using DB Browser for SQLite. I want to connect this database with my android project .. So, where should I put it ? in which folder of my project ? and how can I connect them together ? just with SQLiteOpenHelper ?

Noor
  • 57
  • 1
  • 7
  • 5
    Possible duplicate of [How and where to add sqlite(.db) file in to an android project](https://stackoverflow.com/questions/10579798/how-and-where-to-add-sqlite-db-file-in-to-an-android-project) – Ali Nov 22 '18 at 12:19
  • check this https://stackoverflow.com/questions/513084/ship-an-application-with-a-database – karan Nov 22 '18 at 12:19
  • Welcome to StackOverFlow, please look at the link : https://stackoverflow.com/help/how-to-ask – Arash GM Nov 22 '18 at 12:19
  • You really have to search before asking. If you did, you'd find an answer less than in a minute – Vladyslav Matviienko Nov 22 '18 at 12:24

1 Answers1

0

So, where should I put it ? in which folder of my project ?

Typically you'd put the database file into the assets folder or within a folder within the assets folder.

how can I connect them together ? just with SQLiteOpenHelper ?

You would typically then connect to the database after copying the database from the assets folder to a suitable location (easiest place is in data/data//databases).

Although you could do the above via a subclass of SQLiteOpenHelper, there is a simpler way by using Android SQLiteAssetHelper. Instructions are in the README.

  • Note the database file needs to be copied into the assets/databases folder as that is where SQLiteAssethelper expects the file to be.
MikeT
  • 51,415
  • 16
  • 49
  • 68
  • Where is the assets folder? I couldn`t find it .. also data/data – Noor Nov 25 '18 at 07:49
  • You may need to create assets folder app/main/src if using AssetHelper no need to worry about looking for data/data it will place the db into it. As it basically uses getDatabasepath() method, which will result in data/data/package_name/databases/ – MikeT Nov 25 '18 at 20:09