/**
* 拷贝数据库至file文件夹下
* @param dbName 数据库名称
*/
private void initAddressDB(String dbName) {
//1,在files文件夹下创建同名dbName数据库文件过程
File files=getFilesDir();//获取/data/data//files目录
File file=new File(files,dbName);//创建名为dbName的文件
if(file.exists()){
return;
}
//2.输入流读取第三方资产目录下的文件
InputStream stream=null;
FileOutputStream fos=null;
try {
stream=getAssets().open(dbName);
//3,将读取的内容写入到指定文件夹的文件中去
fos=new FileOutputStream(file);
byte[] bs=new byte[1024];
int temp=-1;
while((temp=stream.read(bs))!=-1){
fos.write(bs,0,temp);
}
} catch (IOException e) {
e.printStackTrace();
}finally {
if(stream!=null&&fos!=null){
try {
stream.close();
fos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有