有关android /data/data/ [
把asset下的数据库xx.db复制到/data/data/package_name/xx.db下,无法复制啊 !!什么问题 ?? 应该不用root吧? 这个目录本身是属于本应用程序的!理论上来说本应用程序是可以访问!
private SQLiteDatabase openDataBase(String path) {
Log.e("SQLite exist:", "" + new File(path).exists() + "::" + path);
// TODO Auto-generated method stub
try {
File file = new File(path);
if (!file.exists()) {// 判断数据库是否存在,若不存在执行导入操作,否则直接打开数据库
// InputStream ins = context.getResources().openRawResource(
// R.raw.ty_city);
file.createNewFile();
InputStream ins = context.getAssets().open("Chinacity.db");
FileOutputStream fos = new FileOutputStream(path);
byte[] buffer = new byte[BUFFER_SIZE];
int count = 0;
while ((count = ins.read(buffer)) > 0) {
fos.write(buffer, 0, count);
Log.e("buffer...", "" + count);
}
fos.close();
ins.close();
}
SQLiteDatabase sqLiteDatabase = context.openOrCreateDatabase(
DB_NAME, 0, null);
return sqLiteDatabase;
} catch (FileNotFoundException ffe) {
ffe.printStackTrace();
Log.e("DataBaseFile:", "file can't find");
} catch (IOException ioe) {
// TODO: handle exception
Log.e("IOException", ioe.getMessage());
ioe.printStackTrace();
}
return null;
}
报错
java.io.IOException: open failed: ENOENT (No such file or directory)//file.createNewFile();
private SQLiteDatabase openDataBase(String path) {
Log.e("SQLite exist:", "" + new File(path).exists() + "::" + path);
// TODO Auto-generated method stub
try {
File file = new File(path);
if (!file.exists()) {// 判断数据库是否存在,若不存在执行导入操作,否则直接打开数据库
// InputStream ins = context.getResources().openRawResource(
// R.raw.ty_city);
file.createNewFile();
InputStream ins = context.getAssets().open("Chinacity.db");
FileOutputStream fos = new FileOutputStream(path);
byte[] buffer = new byte[BUFFER_SIZE];
int count = 0;
while ((count = ins.read(buffer)) > 0) {
fos.write(buffer, 0, count);
Log.e("buffer...", "" + count);
}
fos.close();
ins.close();
}
SQLiteDatabase sqLiteDatabase = context.openOrCreateDatabase(
DB_NAME, 0, null);
return sqLiteDatabase;
} catch (FileNotFoundException ffe) {
ffe.printStackTrace();
Log.e("DataBaseFile:", "file can't find");
} catch (IOException ioe) {
// TODO: handle exception
Log.e("IOException", ioe.getMessage());
ioe.printStackTrace();
}
return null;
}
报错
java.io.IOException: open failed: ENOENT (No such file or directory)//file.createNewFile();
...全文
相关推荐
安卓14使用Android/data(无需shizuku,无需授权)
利用安卓现有漏洞直接像安卓10一样直接使用Android/data目录或者像安卓11一样授权Android/data目录,并且无需shizuku,只是简单写了一个授权和查看文件列表的实例,剩下直接参照
android静默卸载data/app下的应用程序
在Android设备上,应用程序默认安装在系统分区的/data/app/目录下,每个应用程序都有一个对应的APK文件,这个文件包含了应用的所有资源和代码。
解决Android studio中关于模拟器的/data目录不能显示的问题
最后,在刷新一下 Android Device Monitor,发现 data 目录可以打开了,并且还可以打开/data/data/<相应包名>/文件夹。
用系统自带的文件应用拷贝或移动文件无法到storage/emulated/0/Android/data 目录
用系统自带的文件应用拷贝或移动文件无法到storage/emulated/0/Android/data 目录
在 Android 上通过模拟 HTTP multipart/form-data 请求协议信息实现图片上传
在Android平台上,实现图片上传通常涉及使用HTTP协议中的multipart/form-data请求类型,这是处理表单数据,特别是上传文件的标准方式。


