我正在开发一个 android 应用程序,我希望用户能够访问数据目录。我知道你可以这样做,Runtime.getRuntime().exec("su");
但我试过了,它打开了询问你是否想要获得许可的屏幕,但它不允许我在单词之后检索目录。这是代码:
try {
Runtime.getRuntime().exec("su");
final File dataFile = Environment.getDataDirectory();
FileAdapter adapter = new FileAdapter(getActivity());
adapter.setFiles(dataFile.listFiles());
setListAdapter(adapter);
setListShown(true);
} catch (IOException e) {
Toast.makeText(getActivity(),"Sorry, Root access was denied",Toast.LENGTH_LONG).show();
}