I'm using usb debugging(SM - G335h version 4.4.2 API 19) and I want to export the database from android studio but the data folder can't unfold . anyone knows how to fix this? I've tried rooting my phone using adb root but it doesn't work.
Asked
Active
Viewed 29 times
1 Answers
0
A way around this would be to copy the database file to an accessible location from within the App.
Such a location, for example, could be the downloads folder, which can be determined/accessed by using something like:-
File yourdir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getPath());
- Note you'd need to set appropriate permissions.
You could get the Database location using :-
Context.getDatabasePath("your_database_name");
e.g. a very basic/minimal example could be :-
File from = new File(a_suitable_context.getDatabasePath("your_database_name").getPath());
File to = new File(a_suitable_context.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS).getPath() + File.separator + "your_db_savename");
byte[] bffr = new byte[1024];
FileInputStream fsfrom;
FileOutputStream fsto;
try {
fsfrom = new FileInputStream(from);
fsto = new FileOutputStream(to);
while(fsfrom.read(bffr) > 0) {
fsto.write(bffr);
}
fsto.flush();
fsfrom.close();
fsto.close();
} catch (IOException e) {
e.printStackTrace();
}
You could then access this file from AS's device explorer. e.g. :-
Note this uses a sub-directory within the Downloads folder.
Note
a_suitable_context
,your_database_name
andyour_db_savename
would be suitable values that you would supply (the latter could both be the database name).- If the dabase is quite large then you may wish to increase the bfrr size.
You may also be able to use the solution from here Android Device Monitor “data” folder is empty

MikeT
- 51,415
- 16
- 49
- 68