Pulling SQlite database to android device

September 06, 2016 , 0 Comments

This is Easy to Use For Pulling out db from inside the app.
try {
File sd = Environment.getExternalStorageDirectory();//where it store.

File data = Environment.getDataDirectory();

if (sd.canWrite()) {
String currentDBPath
= "/data/data/" + getPackageName() + "/databases/<DATABASENAME>";
String backupDBPath
= "<DATABASENAME>.db";
File currentDB = new File(currentDBPath);
File backupDB = new File(sd, backupDBPath);

if (currentDB.exists()) {
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) {

}

Contributer

Some say he’s half man half fish, others say he’s more of a seventy/thirty split. Either way he’s a fishy bastard. Google

0 comments:

Popular Posts