private void backupData(String fromFile, String toFile) {
File file = new File(fromFile);
File zipfile = new File(
toFile+new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss ").format(new Date(
System.currentTimeMillis())) + ".zip");
try { Toast.makeText(context, "开始备份数据,请等待", Toast.LENGTH_SHORT).show();
InputStream input = new FileInputStream(file);
ZipOutputStream output = new ZipOutputStream(new FileOutputStream(
zipfile));
output.putNextEntry(new ZipEntry(file.getName()));
output.setComment("database backup");
int i = 0;
while ((i = input.read()) != -1) {
output.write(i);
}
input.close();
output.close();
Toast.makeText(context, "备份结束!", Toast.LENGTH_SHORT).show();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
System.out.println(e.getMessage());
Toast.makeText(context, "备份失败!", Toast.LENGTH_SHORT).show();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println(e.getMessage());
Toast.makeText(context, "备份失败!", Toast.LENGTH_SHORT).show();
} }
两个参数分别为:private static final String DBFILE = "/data/data/com.sarnath.notebook/databases/notebook.db ";
               sdPath= Environment.getExternalStorageDirectory().getPath()+"/backupData/";报的错误:/data/data/com.sarnath.notebook/databases/notebook.db  (No such file or directory)
郁闷,这不是db的位置吗,我数据库没有用provider,是在同一个程序中读取的。很纳闷啊,求解!