由网友(忘南忘北不忘你)分享简介:我想从编程资源文件夹保存apk文件在Android系统/应用程序文件夹中。I am trying to programatically save apk file from asset folder to system/app folder in android.我使用以下code。但错误显示只读文件系统。I a...
我想从编程资源文件夹保存apk文件在Android系统/应用程序文件夹中。
I am trying to programatically save apk file from asset folder to system/app folder in android.
我使用以下code。但错误显示只读文件系统。
I am using following code. but error is showing read only file system.
AssetManager assetManager = getAssets();
InputStream in = null;
OutputStream out = null;
try {
in = assetManager.open("youtuberanjit.apk");
out = new FileOutputStream("/system/app/youtuberanjit.apk");
byte[] buffer = new byte[1024];
int read;
while((read = in.read(buffer)) != -1){
out.write(buffer, 0, read);
}
in.close();
in = null;
out.flush();
out.close();
out = null;
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(
Uri.fromFile(new File("/system/app/youtuberanjit.apk")), "application/vnd.android.package-archive");
startActivity(intent);
}catch(Exception e){
// deal with copying problem
Log.e("ERRORR", ""+e.getMessage());
}
请帮助我。
感谢您!
推荐答案
您不能,除非你有权利这样做,写 /系统
。您将需要一个根深蒂固的设备。
You cannot write to /system
unless you have rights to do that. You will need a rooted device for that.
为什么你希望它是一个系统的应用程序,而不是一个正常的用户应用?
Why do you want it to be a system app, and not a 'normal' user app?
相关推荐
最新文章