原文:https://blog.csdn.net/kqz2014/article/details/78466113
//找到文件的路径 /data/data/包名/databases/数据库名称
File dbFile = new File(Environment.getDataDirectory().getAbsolutePath() + "/data/" + mContext.getPackageName() + "/databases/你自己的数据库名称.db");
FileInputStream fis = null;
FileOutputStream fos = null;
try {
//文件复制到sd卡中
fis = new FileInputStream(dbFile);
fos = new FileOutputStream(Environment.getExternalStorageDirectory().getAbsolutePath() + "/copy_database.db");
int len = 0;
byte[] buffer = new byte[2048];
while (-1 != (len = fis.read(buffer))) {
fos.write(buffer, 0, len);
}
fos.flush();
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (fos != null) fos.close();
if (fis != null) fis.close();
Toast.makeText(mContext, "copy结束", Toast.LENGTH_SHORT).show();
} catch (IOException e) {
e.printStackTrace();
}
}