我试图从data/data
访问我的应用程序的文件夹,但它需要的权限更改为0777
。所以,我使用了一些可以在运行时更改的代码,但权限不会改变。它给我错误open failed: EACCES (Permission denied)
。我也把这个权限在下面棉花糖清单文件我需要给像根探险家,我们更改文件夹rwxrwxrw需要访问系统的权限
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
这里,这是我的代码
String[] command = new String[]{"/system/bin/ls", "0777",
"/data/data/com.ayub.android.baba" };
process = Runtime.getRuntime().exec(command);
BufferedReader reader = new BufferedReader(
new InputStreamReader(process.getInputStream()));
int read;
String output = "";
String line;
while ((line = reader.readLine()) != null) {
output.concat(line + "\n");
Log.w("myApp", "[[output]]:" + line);
process.waitFor();
}
reader.close();
process.waitFor();
} catch (Exception e) {
Toast.makeText(this, e.toString(), Toast.LENGTH_SHORT).show();
Log.d(TAG,e.toString());
}
您需要添加运行时间在访问任何危险权限之前。 –
'ls'不适合更改权限。 –
https://developer.android.com/training/permissions/requesting.html –