如何从内部存储中获取存储的SQLite数据

时间:2014-04-29 06:20:38

标签: android export android-sqlite

我将一些数据存储到SQLite数据库中,现在我必须从设备的内部存储器中获取这些数据,我使用的是下面的代码,但是在按下按钮时没有发生任何事情

File sd = Environment.getExternalStorageDirectory();
File data = Environment.getDataDirectory();
FileChannel source=null;
FileChannel destination=null;
  String currentDBPath = "/data/data/app.church.sophie/databases/churchdb.db";
           String backupDBPath = "SAMPLE_DB_NAME";
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(ExportDataActivity.this, "DB Exported!", Toast.LENGTH_LONG).show();
    } catch(IOException e) {
        e.printStackTrace();
         }
}

0 个答案:

没有答案