I am making an application using Android Studio. I put the database.db file in the asset folder. What is the correct path to use to open the database?
-
1You must copy the db from the `assets` folder to the `/data/data/...` folder (if you want to keep the db private) or to the storage. – Phantômaxx Feb 08 '15 at 16:53
-
how can i put the db file /data/data/.. – Karim Gehad Feb 08 '15 at 17:17
-
http://stackoverflow.com/questions/9109438/how-to-use-an-existing-database-with-an-android-application/9109728#9109728 – Phantômaxx Feb 08 '15 at 17:22
-
i have already a db file in my computer how can i move it to /data/data – Karim Gehad Feb 08 '15 at 17:49
-
You should put it in your assets folder, then programmatically copy it to the path. Please read the answer in the above link. – Phantômaxx Feb 08 '15 at 17:52
-
The correct path is (if you want to keep the db private) `/data/data/your.app.name/databases/`. Where `your.app.name` is the complete package name. – Phantômaxx Feb 08 '15 at 18:18
-
You can even access this folder in your DDMS, to see that everything works correctly. – Phantômaxx Feb 08 '15 at 18:38
1 Answers
*)run your app on emulator
*)click the "window" button on the title bar
*)select the open perspective on it's list view
*)select the DDMS option[this will return to a new page] On that new window select your emulator (on the left side of your window it will show your currently working emulator's from that select the one that you run the app)
*)Then it will display all the files on your system From that go to "data" file
*)Again in that data file there is another file call on "data" click it then it display your application name's by it's package name select the package that you run early
*)On that file there is a folder call "Databases" if and only if your database was created when you running the application.
*)on that there is a file in your data base name. that is your db file if you run on emulator you can view it, but if you run on phone you haven't permission for view it.

- 923
- 13
- 24
-
The OP wants to do that programmatically. http://stackoverflow.com/questions/9109438/how-to-use-an-existing-database-with-an-android-application/9109728#9109728 – Phantômaxx Feb 08 '15 at 17:23