Streetboy
Streetboy

Reputation: 4401

How to get sqlite from databases folder in device?

Hello i had implemented this code Using your own SQLite database in Android applications

It takes my db from assets folder and copy it in databases folder into device. Now how could i get that databse from my device ?

or to get is just possible if my device is rooted or even then it's can't be done ?

Thanks.

Upvotes: 0

Views: 742

Answers (1)

PrincessLeiha
PrincessLeiha

Reputation: 3174

"currentDBPath" contains the path of the DB. You can copy it as a file and save it some where else using the following steps.

String currentDBPath = "/data/"+getApplicationInfo().packageName+"/databases/db_name";

FileChannel src = new FileInputStream(currentDB).getChannel(); // source
FileChannel dst = new FileOutputStream(backupDB).getChannel(); // destination
dst.transferFrom(src, 0, src.size()); // to copy from source to destination
src.close();
dst.close();

Hope this is what you are looking for.

Upvotes: 1

Related Questions