I am quite new to android development and right now I\'m trying to create a database through a class extending SQLiteOpenHelper. I am positively sure that the data is being sto
if you are trying to get database which is stored in applicaiton package from device thn you will not get direct access from device /data/data/app packagename/databases/ ..you can access and modify using helperclass bt direct export nt poss AFAIK ... bt from emulator u cn gt
If you to export database from in sd card from application package
try this
private void copyFromDataPackgeToSdCard() throws IOException {
try {
File sdCard = Environment.getExternalStorageDirectory();
File appDataDir = Environment.getDataDirectory();
if (sdCard.canWrite()) {
String currentDBPath = "//data//" + getPackageName()
+ "//databases//"
+ DatabaseImplementation.DATABASE_NAME;
String backupDBPath = DatabaseImplementation.DATABASE_NAME;
File currentDatabase = new File(appDataDir, currentDBPath);
File backupDatabase = new File(sdCard, backupDBPath);
if (currentDatabase.exists()) {
FileChannel src = new FileInputStream(currentDatabase)
.getChannel();
FileChannel dst = new FileOutputStream(backupDatabase)
.getChannel();
dst.transferFrom(src, 0, src.size());
src.close();
dst.close();
}
}
} catch (Exception e) {
Log.e("copyFromDataPackgeToSdCard", e.getMessage());
}
}
How about setting the dbname as full path:
String DATABASE_NAME = "/data/data/"+packageName+"db.db";
or put your db in SD card:
String DATABASE_NAME= Environment.getExternalStorageDirectory()+packageName+"db.db";
pass the dbPath in your code:
public DatabaseImplementation(Context context)
{
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}