Android copyFile SDcard

时间:2014-01-13 17:31:39

标签: android sqlite

我已成功导入库“com.ipaulpro.afilechooser.utils.FileUtils”以导出和导入SD卡上的数据库。但是在课堂上我遇到了错误:FileUtils.copyFile(internalDB, externalDB);

File internalDB = new File("/data/data/"+getPackageName()+"/databases/MyDatabase.db");
            File externalDB = new File(Environment.getExternalStorageDirectory(), getPackageName()+"/database/MyDatabase.db");

                    try {
                        FileUtils.copyFile(internalDB, externalDB);
                        Toast toast = Toast.makeText(getApplicationContext(),(R.string.Toast_export), Toast.LENGTH_SHORT);
                        //toast.setGravity(Gravity.TOP|Gravity.LEFT, 0, 0);
                        toast.show();

                    } catch (IOException e) {
                        e.printStackTrace();
                        Toast toast = Toast.makeText(getApplicationContext(),(R.string.Toast_export_errore), Toast.LENGTH_SHORT);
                        toast.show();
                            }

0 个答案:

没有答案