Android-创建多个导出的数据库,并允许用户选择要导入的数据库

Android-创建多个导出的数据库,并允许用户选择要导入的数据库,android,sqlite,Android,Sqlite,我有以下代码,用于创建SQLite数据库的备份 File sd = Environment.getExternalStorageDirectory(); File data = Environment.getDataDirectory(); FileChannel source = null; FileChannel destination = null; String currentDBPath = "/data/com.sjhdevelopment.s

我有以下代码,用于创建SQLite数据库的备份

    File sd = Environment.getExternalStorageDirectory();
    File data = Environment.getDataDirectory();
    FileChannel source = null;
    FileChannel destination = null;
    String currentDBPath = "/data/com.sjhdevelopment.shaunharrison.myejuiceapp/databases/EJuiceData.db";
    String backupDBPath = "EJuiceData.db";


    File currentDB = new File(data,currentDBPath);
    File backupDB = new File(sd,backupDBPath);

    try
    {
        source = new FileInputStream(currentDB).getChannel();
        destination = new FileOutputStream(backupDB).getChannel();
        destination.transferFrom(source,0,source.size());
        source.close();
        destination.close();
        Toast.makeText(this, "DB Exported", Toast.LENGTH_LONG).show();
    }
    catch(Exception e)
    {
        showError("Error", e.getMessage());
    }
我有以下代码来导入SQLite数据库

 File sd = Environment.getExternalStorageDirectory();
 File data = Environment.getDataDirectory();

 if(sd.canWrite())
 {
   String currentDBPath="/data/com.sjhdevelopment.shaunharrison.myejuiceapp/databases/EJuiceData.db";
   String backupDBPath = "EJuiceData.db";
   File backupDB = new File (data,currentDBPath);
   File currentDB = new File(sd, backupDBPath);

   try {
         FileChannel src =new FileInputStream(currentDB).getChannel();
         FileChannel dst = new FileOutputStream(backupDB).getChannel();
         dst.transferFrom(src, 0, src.size());
         src.close();
         dst.close();
         Toast.makeText(getBaseContext(), "DB Imported", Toast.LENGTH_LONG).show();
       }
   catch(Exception e)
   {
         showError("Error", e.getMessage());
   }
我的问题是,我现在希望用户能够进行多个备份,而不仅仅是一个备份,我知道如何通过以下方式获取今天的日期:

    Calendar calendar = Calendar.getInstance();
    Date today = calendar.getTime();
    DateFormat dateFormat = new SimpleDateFormat("dd/MMM/yyyy");
    String todayAsString = dateFormat.format(today);
但是今天的字符串在代码导出代码中的什么地方呢

另外,在导入时,如何允许用户浏览其文件以选择要导入的备份

谢谢

您可以使用。唯一的选择就是你想要的