博客
关于我
数据库导出、导入
阅读量:514 次
发布时间:2019-03-07

本文共 1726 字,大约阅读时间需要 5 分钟。

1、数据库导出:

//导出数据库private void backupDatabase() {public static final String DATABASES_PATH = "/data/data/com.zhuang.database/databases";        File srcDir = new File(Constants.DATABASES_PATH);        //一级目录        public static String APPDIR = "离线数据";                      File destDir = new File(FileUtil.getSDCardPath() + Constants.APPDIR + File.separator + "databases");        AppExecutors.getInstance().diskIO().execute(() -> {            boolean isSuccess = FileUtils.copyDir(srcDir, destDir);            AppExecutors.getInstance().mainThread().execute(() -> {                //
成功备份到:%s
//
备份失败
Toast.makeText(this,isSuccess ? getString(R.string.successfully_backed_up_to, destDir) : getString(R.string.backup_failed),Toast.LENGTH_SHORT).show(); dismissDialog(); }); }); }

2、导入数据库:

private void importDatabase() {        File srcDir = new File(FileUtil.getSDCardPath() + Constants.APPDIR + File.separator + "databases");        if (!srcDir.exists()) {            ToastUtils.showShort(srcDir.toString() + getString(R.string.directory_does_not_exist));            return;        }        File destDir = new File(Constants.DATABASES_PATH);        AppExecutors.getInstance().diskIO().execute(() -> {            boolean isSuccess = FileUtils.copyDir(srcDir, destDir);            AppExecutors.getInstance().mainThread().execute(() -> {                //
成功导入到:%s
//
导入失败
Toast.makeText(this,isSuccess ? getString(R.string.successfully_imported_to2, destDir) : getString(R.string.imported_failed),Toast.LENGTH_SHORT).show(); dismissDialog(); }); }); }

 

转载地址:http://arknz.baihongyu.com/

你可能感兴趣的文章
MySQL高频面试题
查看>>
MySQL高频面试题的灵魂拷问
查看>>
MySQL(1)的使用 | SQL
查看>>
MySQL(2)DDL详解
查看>>
MySQL(3)DML详解
查看>>
MySQL(4)运算符 | 关联查询详解
查看>>
MySQL(5)条件查询 | 单行函数 | 事务详解
查看>>
Mysql,group by分组查询、order by排序查询、join连接查询、union联合查询
查看>>
Mysql,sql文件导入和导出
查看>>
MYSQL:int类型升级到bigint,对PHP开发语言影响
查看>>
Mysql:mysql 5.X 报错 ERROR 1193 (HY000): Unknown system variable ‘validate_password_length‘
查看>>
MySQL:MySQL执行一条SQL查询语句的执行过程
查看>>
Mysql:SQL性能分析
查看>>
mysql:SQL按时间查询方法总结
查看>>
MySQL:什么样的字段适合加索引?什么样的字段不适合加索引
查看>>
MySQL:判断逗号分隔的字符串中是否包含某个字符串
查看>>
MySQL:某个ip连接mysql失败次数过多,导致ip锁定
查看>>
MySQL:索引失效场景总结
查看>>
Mysql:避免重复的插入数据方法汇总
查看>>
MyS中的IF
查看>>