android assets文件夹下的数据库应用

//当数据库大于1M时,要用FileSplit工具软件把文件分割成小于1M的小文件
	// 复制assets下的大数据库文件时用这个
	private void copyBigDataBase() {
		File file = new File(DB_PATH);
		if (file.exists()) {
			return;
		}
		
		mHandler.sendEmptyMessage(2);
		
		try {
			InputStream myInput;
			String outFileName = DB_PATH;
			OutputStream myOutput = new FileOutputStream(outFileName);
			for (int i = 0; i < 19; i++) {
				myInput = getAssets().open("joke.db.3h" + i);
				byte[] buffer = new byte[1024];
				int length;
				while ((length = myInput.read(buffer)) > 0) {
					myOutput.write(buffer, 0, length);
				}
				myOutput.flush();
				myInput.close();
				System.out.println("copy------>" + i);
			}
			
			myOutput.close();
			mHandler.sendEmptyMessage(1);
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}


你可能感兴趣的:(数据库,android,File,buffer,Path,byte)