Reputation: 147
I have my Android application in which i m using SQLite database. Everything is working fine. But i want to download .db file to check my Database schema and data in database. But i don't know how to copy SQLite .db file from android device. i m using Google Nexus 7 for my development. please help me on that Thanks in advance
Upvotes: 3
Views: 7515
Reputation: 3480
Hi you want o Download SQLite Database Browser Click here to download and then in Eclipse select your project and go to DDMS window there you will find a Sub-window which consists of tabs click on File Explorer and Click on data folder a drop down folder will come and again click on the data folder Now you can see all your projects loaded in eclipse then select your project if it consists Database means it will show you database folder click on that you will find your DB select the DB you want click on Save Icon (Pull a file from device) and then save your db. Now open the download SQLite db browser and browse the .db extension file you can view you Database .
Upvotes: 2
Reputation: 2117
You can use the adb pull command to read a file from the teathered device to your desktop.
E.g. adb pull /data/data/com.foo.bar/databases/MyDatabase
Upvotes: 6
Reputation: 5515
use this method to copy database to external data storage of device
private void copyDbToExternal(Context context) {
try {
File sd = Environment.getExternalStorageDirectory();
File data = Environment.getDataDirectory();
if (sd.canWrite()) {
String currentDBPath = "//data//data//" + context.getApplicationContext().getPackageName() + "//databases//"
+ DB_NAME;
String backupDBPath = DB_NAME;
File currentDB = new File(data, currentDBPath);
File backupDB = new File(sd, backupDBPath);
FileChannel src = new FileInputStream(currentDB).getChannel();
FileChannel dst = new FileOutputStream(backupDB).getChannel();
dst.transferFrom(src, 0, src.size());
src.close();
dst.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
Upvotes: 0