private void copyDB(){
File f = new File("/data/data/xxx/databases/xxx.db");
File o = new File("/storage/udisk/xxx.db"); //sdcard上的目标地址
if(f.exists()) {
FileChannel outF;
try {
outF = new FileOutputStream(o).getChannel();
new FileInputStream(f).getChannel().transferTo(0, f.length(),outF);
Toast.makeText(SplashActivity.this, "完成", Toast.LENGTH_SHORT).show();
} catch (FileNotFoundException e) {
Toast.makeText(SplashActivity.this, "未检测到U盘", Toast.LENGTH_SHORT).show();
e.printStackTrace();
} catch (IOException e) {
Toast.makeText(SplashActivity.this, "未检测到U盘", Toast.LENGTH_SHORT).show();
e.printStackTrace();
}
}
}
private void upgradeDB(){
File f = new File("/storage/udisk/xxx.db");
File o = new File("/data/data/xxx/databases/xxx.db"); //sdcard上的目标地址
if(f.exists()) {
FileChannel outF;
try {
outF = new FileOutputStream(o).getChannel();
new FileInputStream(f).getChannel().transferTo(0, f.length(),outF);
Toast.makeText(SplashActivity.this, "完成", Toast.LENGTH_SHORT).show();
} catch (FileNotFoundException e) {
e.printStackTrace();
Toast.makeText(SplashActivity.this, "未检测到U盘", Toast.LENGTH_SHORT).show();
} catch (IOException e) {
e.printStackTrace();
Toast.makeText(SplashActivity.this, "未检测到U盘", Toast.LENGTH_SHORT).show();
}
}
}