1
我想创建一个小应用程序,它需要在/系统文件夹(它试图删除一个文件,并创建一个新的而不是它)的读/写访问。 我能够重新安装该文件夹没有问题与adb,如果我这样做,当然我的应用程序工作正常,直到重新启动。从应用程序重新安装/系统
我的设备是根源(sgs3与股票4.1.2)。我可以在没有问题的情况下获得root权限 - 我可以在弹出消息的地方启用它。但在此之后,它并不真正对命令做出响应。
我有这样的事情:
//at this point I get the popup to grant root access
Runtime.getRuntime().exec("su");
//no error messages - not on console, not in logcat
Runtime.getRuntime().exec("mount -w -o remount -t ext4 /dev/block/mmcblk0p9 /system");
//trying to do things in the system folder...
FileWriter fw=new FileWriter(file);
fw.write("a");
fw.close();
//trying to remount the folder as read only only once everything is done
Runtime.getRuntime().exec("mount -r -o remount -t ext4 /dev/block/mmcblk0p9 /system");
如果我运行从亚行外壳相同的重新挂载命令,一切都是完美的。如果我不运行它,但要尽量依靠应用程序,我得到了以下错误消息(IOException异常抛出),从文件系统时,我尝试写/删除:
open failed: EROFS (read-only file system)
一些额外的信息:我我正在使用2.2 SDK,在我的清单文件中有WRITE_EXTERNAL_STORAGE权限(尽管我不确定是否需要它,因为我尝试使用内部存储)。
欢迎任何想法。
哇,它似乎工作。需要一些练习,但它会是完美的。谢谢! – skandigraun