最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

android 拷貝sqlite數(shù)據(jù)庫到本地sd卡的方法

 更新時間:2017年03月12日 11:37:13   投稿:jingxian  
下面小編就為大家?guī)硪黄猘ndroid 拷貝sqlite數(shù)據(jù)庫到本地sd卡的方法。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧

sqlite小型數(shù)據(jù)庫,在開發(fā)的時候用于保存數(shù)據(jù),在這不做關(guān)于它的介紹,本文只是寫出了怎么拷貝應(yīng)用的數(shù)據(jù)到本地sd卡中。如:一個數(shù)據(jù)庫名為dandy.db的,拷貝到本地中叫seeker.db

代碼如下:

	/**
	 * 拷貝數(shù)據(jù)庫到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();
			}
		}
	}

以上這篇android 拷貝sqlite數(shù)據(jù)庫到本地sd卡的方法就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論

克拉玛依市| 明光市| 东兰县| 新兴县| 林芝县| 县级市| 宜章县| 常熟市| 修水县| 景洪市| 平南县| 吉林市| 东辽县| 长宁区| 怀远县| 邯郸县| 奉新县| 苍溪县| 当涂县| 连城县| 嘉兴市| 南投县| 高州市| 本溪市| 土默特左旗| 东乡县| 涿州市| 西昌市| 措勤县| 玉山县| 湘潭县| 天峨县| 肥东县| 丰城市| 平遥县| 渭南市| 大宁县| 昌吉市| 屏山县| 望江县| 广灵县|