簡體   English   中英

如何使用存儲訪問框架訪問“ /”(根)目錄

[英]How to get access to “/” (root) directory using Storage Access framework

我試圖在Android 7.0及更高版本上使用Storage Access Framework訪問"/" (根)目錄,在GitHub上查看Google示例后,我可以看到在使用StorageVolume創建accessIntent時僅傳遞了預定義目錄類,但是如何訪問除這些預定義目錄之外的任何其他目錄?

這是我嘗試的代碼:

    StorageManager storageManager = (StorageManager) getSystemService(Context.STORAGE_SERVICE);
    File root = new File("/");
    StorageVolume storageVolume = storageManager.getStorageVolume(root);

    Intent intent = storageVolume.createAccessIntent("/");
    startActivityForResult(intent, REQUEST_CODE);

我的存儲卷為null,無法使用StorageVolume框架訪問“ /”目錄。

如何在Android 7.0及更高版本上使用Storage Access Framework"/"目錄進行范圍目錄訪問

如果設備不是root用戶,則無法訪問root文件夾。 https://stackoverflow.com/a/5293771/4284706https://stackoverflow.com/a/5436182/4284706答案,如果你的設備是植根。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM