java 在 DDMS (Android) 中更改文件权限
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7473573/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Change file permissions in DDMS (Android)
提问by Swato
I'm trying to test the behavior of my application when it cannot access some files due to missing permissions.
当我的应用程序由于缺少权限而无法访问某些文件时,我正在尝试测试它的行为。
Is it possible to change file/folder permissions on an android emulator using FileExplorer in DDMS perspective?
是否可以在 DDMS 角度使用 FileExplorer 更改 android 模拟器上的文件/文件夹权限?
回答by Dyonisos
To change permissions in the emulator you need to use the adb shell
command from your adroid-sdk platform-tools. In the android shell you can enter the command su
to get root access. Now you can see and change the permissions with the normal unix commands chmod
要更改模拟器中的权限,您需要使用adb shell
来自您的 adroid-sdk 平台工具的命令。在 android shell 中,您可以输入命令su
以获取 root 访问权限。现在您可以使用普通的 unix 命令查看和更改权限chmod
Note, that the system folder in Android is mounted read-only. You would have to remout it read-write after this tutorial:
请注意,Android 中的系统文件夹以只读方式挂载。在本教程之后,您将不得不以读写方式重新安装它:
http://android-tricks.blogspot.com/2009/01/mount-filesystem-read-write.html
http://android-tricks.blogspot.com/2009/01/mount-filesystem-read-write.html
Be careful in anyway to use only writable filesystems like /data
or sdcard
for your application data since using restricted folders can have negative side effects in a productive environment!
无论如何都要小心,只使用可写的文件系统,如/data
或sdcard
用于您的应用程序数据,因为在生产环境中使用受限文件夹可能会产生负面影响!