I'm copying my db file to sd car using this methode please tell me if file at sdcard is already existing then whether it will replace or will not copy?
public boolean copyDbToSDCard() {
boolean success = false;
String SDCardPath = Environment.getExternalStorageDirectory()
.getAbsolutePath();
final String DBPATH = SDCardPath + "/BD/";
final String DBNAME = "Mydb3.db";
this.getReadableDatabase();
File directory = new File(DBPATH);
if (!directory.exists())
directory.mkdir();
close();
try {
InputStream mInput = new FileInputStream(DB_PATH + DB_NAME);
OutputStream mOutput = new FileOutputStream(DBPATH + DBNAME);
byte[] buffer = new byte[1024];
int length;
while ((length = mInput.read(buffer)) > 0) {
mOutput.write(buffer, 0, length);
}
mOutput.flush();
mOutput.close();
mInput.close();
success = true;
} catch (Exception e) {
Toast.makeText(myContext,
"copyDbToSDCard Error : " + e.getMessage(),
Toast.LENGTH_SHORT).show();
e.fillInStackTrace();
}
return success;
}