I am trying to export an sqlite database to the sdcard. When I test the application (both on real device and on emulator) I get an error regarding the path of my database. When I check from the DDMS the path of the database it seems to be the one that is printed as not found.
File dbFile =
new File(Environment.getDataDirectory() + "/data/"+c.getPackageName()+"/databases/myDB.db");
AndroidManifest.xml
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
I used the code found here:
Making a database backup to SDCard on Android
Firstly, don’t use hardcoded paths for anything in Android – they’re not guaranteed to be the same across all devices.
Try using
getDatabasePath("myDB.db").getAbsolutePath();