博客
关于我
数据库导出、导入
阅读量: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遇到Deadlock found when trying to get lock,解决方案
查看>>
mysql部署错误
查看>>
MySQL配置信息解读(my.cnf)
查看>>
Mysql配置文件my.ini详解
查看>>
MySQL配置文件深度解析:10个关键参数及优化技巧---强烈要求的福利来咯。
查看>>
Mysql配置表名忽略大小写(SpringBoot连接表时提示不存在,实际是存在的)
查看>>
mysql配置读写分离并在若依框架使用读写分离
查看>>
MySQL里为什么会建议不要使用SELECT *?
查看>>
MySQL里的那些日志们
查看>>
MySQL锁
查看>>
MySQL锁与脏读、不可重复读、幻读详解
查看>>
MySQL锁机制
查看>>
mysql锁机制,主从复制
查看>>
Mysql锁机制,行锁表锁
查看>>
MySQL锁表问题排查
查看>>
Mysql锁(1):锁概述和全局锁的介绍
查看>>
Mysql锁(2):表级锁
查看>>
MySQL锁,锁的到底是什么?
查看>>
MySQL错误-this is incompatible with sql_mode=only_full_group_by完美解决方案
查看>>
Mysql错误2003 -Can't connect toMySQL server on 'localhost'(10061)解决办法
查看>>