【发布时间】:2011-07-12 21:37:57
【问题描述】:
嗨,我正在开发一个简单的启动动画应用程序,但我猜这是一个权限问题,但我不太确定,因为我是新手,但无论如何这是我的代码。我正在尝试将启动动画从 sdcard 复制到 /data/local 并将其重命名为 bootanimation.zip 我知道代码很好,因为如果我复制到 sdcard 上的另一个文件夹说 /mnt/sdcard/folder/bootanimation。 zip 它可以工作并且文件被重命名,但我无法复制到 /data/local 我的手机已植根,但我猜我的应用程序需要请求 su 或者我的清单需要更多权限。关于为什么我不能复制到 /data/local 的任何解决方案都会有很大的帮助。感谢您的帮助
try {
FileChannel srcChannel = new FileInputStream("/mnt/sdcard/boots/1bootanimation.zip").getChannel();
FileChannel dstChannel = new FileOutputStream("/data/local/bootanimation.zip").getChannel();
dstChannel.transferFrom(srcChannel, 0, srcChannel.size());
srcChannel.close();
dstChannel.close();
} catch (IOException e) {
}
【问题讨论】:
-
您必须将 /data/ 重新挂载为 rw(读写),默认为 ro(只读)。通常这是可能的,但由于您的手机已植根它是可行的。
-
哈哈,我觉得自己很愚蠢 :) 没想到我会需要 su 来写入数据,但这是有道理的,哈哈,喜欢小事
-
会不会和 bash 中的一样(在我第一个应用程序之前是一个脚本编写者),即 mount -o rw,remount -t yaffs2 /dev/block/mtdblock3 /data跨度>
-
是的,我认为
exec("su");然后exec("mount -o rw,remount -t yaffs2 /dev/block/mtdblock3 /data");应该可以解决问题。
标签: android copy inputstream boot