0

I alredy checked all th questions and nothing seems help , my problem is the database works fine with the emulator using the absolute path of the database :

String path = "/data/data/com.example.??/databases/database.db";

but when i export it as apk file the the device can't open or find the database with that path !

is that mean when i export it the real path will change ? or just i need to copy my database to specified folder in the device ,, ? can any one help me with this ,, thanks !

  • Do you mean when you launch to a real device? Because if that's the case, the database is not part of the APK. You would have to create a new one in the launched device. – Daniel May 18 '16 at 19:31
  • i have created my database using sqlite db browser ,, it contains images ,, and i import it to my project using the android device monitor , if the database is not part of the APK file how can i attach the database with it ? – Admiral-ahmed May 18 '16 at 19:38
  • So you created a Database outside of Android Studio and imported into your project & you're trying to access it and it works when you do it in the emulator but not with a real device? – Daniel May 18 '16 at 19:42
  • yes thats the case – Admiral-ahmed May 18 '16 at 19:44
  • As far as I know, you can't copy into a real device unless you root the device. – Daniel May 18 '16 at 19:45
  • ahh okay :/ ,, thnx mate , appreciate ur answers :) – Admiral-ahmed May 18 '16 at 19:53
  • If you can export the working DB with DB Browser, could you use the export file in an init script? – Justin Smith May 18 '16 at 21:21
  • 1
    i have no idea about that , but i did solve my problem , the solution is - you should 1st have the database file in the assets folder in the project , and then the app should copie the database from the assests folder to the application, also i found this article " http://blog.reigndesign.com/blog/using-your-own-sqlite-database-in-android-applications/ " it was so useful for me . – Admiral-ahmed May 18 '16 at 21:52
  • I like your solution, suggest you answer the question and mark as solved! – Justin Smith May 19 '16 at 15:48

0 Answers0