android:拷贝sqlite数据库到本地sd卡
来源:互联网 发布:网络绘画班哪个好 编辑:程序博客网 时间:2024/05/18 09:12
sqlite小型数据库,在开发的时候用于保存数据,在这不做关于它的介绍,本文只是写出了怎么拷贝应用的数据到本地sd卡中。如:一个数据库名为dandy.db的,拷贝到本地中叫seeker.db,代码如下:
/** * 拷贝数据库到sd卡 * * @deprecated <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> */public static void copyDataBaseToSD(){ if (!Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) { return ; } File dbFile = new File(MvpApplication.getApplication().getDatabasePath("dandy")+".db"); File file = new File(Environment.getExternalStorageDirectory(), "seeker.db"); FileChannel inChannel = null,outChannel = null; try {file.createNewFile();inChannel = new FileInputStream(dbFile).getChannel();outChannel = new FileOutputStream(file).getChannel();inChannel.transferTo(0, inChannel.size(), outChannel);} catch (Exception e) {LogUtils.e(TAG, "copy dataBase to SD error.");e.printStackTrace();}finally{try {if (inChannel != null) {inChannel.close();inChannel = null;}if(outChannel != null){outChannel.close();outChannel = null;}} catch (IOException e) {LogUtils.e(TAG, "file close error.");e.printStackTrace();}}}
0 0
- android:拷贝sqlite数据库到本地sd卡
- Android 拷贝db文件到sqlite数据库。
- Android 将assets中的文件拷贝到本地SD卡使用
- Android SD 卡上创建 SQLite 数据库
- Android 操作数据库Sqlite,数据写入到SD卡里面
- android保存图片到本地sd卡
- Android 保存View到本地SD卡
- Android sqlite本地数据库
- Android sqlite本地数据库
- android将res中的资源拷贝到SD卡中
- Android 递归实现assets拷贝到sd卡
- android复制数据库到SD卡
- android复制数据库到SD卡
- android复制数据库到SD卡
- 把android数据库复制到sd卡
- android创建数据库到SD卡
- android 建数据库 SQLite 存储sd 卡或者内存
- Android开发-SQLite从资源文件中数据库复制到SD到增删改查-AndroidStudio
- LinkedHashMap源码分析与LRU实现
- 用PE修复NTLDR is missing
- achartengine 使用备忘
- 图片处理view - 成图,
- Robotium 运行时Installation error INSTALL_FAILED_VERSION_DOWNGRADE错误
- android:拷贝sqlite数据库到本地sd卡
- 5+plus教程-1
- eclipse切换至分支报错:Authorization failed
- 用C语言写一个订座系统
- shell sort
- initialize 的用处
- Spring、Struts2+Spring+Hibernate整合步骤
- sql 的join on 和 where 区别
- Android 5.0 双卡信息管理分析