我试图让用户通过各种方式从数据/数据目录导入和导出他们的sqlite数据库,例如电子邮件,onedrive,谷歌驱动器,内部和外部存储等。我不太清楚如何做到这一点。我目前有以下代码将其保存到SD卡中。我不确定如何离开这里。
public static void export() throws IOException {
//Open your local db as the input stream
String inFileName = "/data/data/com.example.main/databases/myDB";
File dbFile = new File(inFileName);
FileInputStream fis = new FileInputStream(dbFile);
String outFileName = Environment.getExternalStorageDirectory()+"/myDB";
//Open the empty db as the output stream
OutputStream output = new FileOutputStream(outFileName);
//transfer bytes from the inputfile to the outputfile
byte[] buffer = new byte[1024];
int length;
while ((length = fis.read(buffer))>0){
output.write(buffer, 0, length);
}
//Close the streams
output.flush();
output.close();
fis.close();
}
有人可以帮助我,并告诉我如何使用电子邮件,onedrive等用户在其设备上安装的可用媒体来导出SQLite数据库。