Get from :
https://github.com/1hakr/AnExplorer/blob/master/app/src/main/java/dev/dworks/apps/anexplorer/provider/ExternalStorageProvider.javaprivate void updateVolumesLocked() { mRoots.clear(); int count = 0; StorageUtils storageUtils = new StorageUtils(getContext()); for (StorageVolume storageVolume : storageUtils.getStorageMounts()) { final File path = storageVolume.getPathFile(); String state = EnvironmentCompat.getStorageState(path); final boolean mounted = Environment.MEDIA_MOUNTED.equals(state) || Environment.MEDIA_MOUNTED_READ_ONLY.equals(state); if (!mounted) continue; final String rootId; final String title; if (storageVolume.isPrimary()) { rootId = ROOT_ID_PRIMARY_EMULATED; title = getContext().getString(R.string.root_internal_storage); } else if (storageVolume.getUuid() != null) { rootId = ROOT_ID_SECONDARY + storageVolume.getUuid(); String label = storageVolume.getUserLabel(); title = !TextUtils.isEmpty(label) ? label : getContext().getString(R.string.root_external_storage) + (count > 0 ? " " + count : ""); count++; } else { Log.d(TAG, "Missing UUID for " + storageVolume.getPath() + "; skipping"); continue; } if (mRoots.containsKey(rootId)) { Log.w(TAG, "Duplicate UUID " + rootId + "; skipping"); continue; } try { if(null == path.listFiles()){ continue; } final RootInfo root = new RootInfo(); mRoots.put(rootId, root); root.rootId = rootId; root.flags = Root.FLAG_SUPPORTS_CREATE | Root.FLAG_SUPPORTS_EDIT | Root.FLAG_LOCAL_ONLY | Root.FLAG_ADVANCED | Root.FLAG_SUPPORTS_SEARCH | Root.FLAG_SUPPORTS_IS_CHILD; root.title = title; root.path = path; root.docId = getDocIdForFile(path); } catch (FileNotFoundException e) { throw new IllegalStateException(e); } }}
private void updateVolumesLocked() { mRoots.clear(); int count = 0; StorageUtils storageUtils = new StorageUtils(getContext()); for (StorageVolume storageVolume : storageUtils.getStorageMounts()) { final File path = storageVolume.getPathFile(); String state = EnvironmentCompat.getStorageState(path); final boolean mounted = Environment.MEDIA_MOUNTED.equals(state) || Environment.MEDIA_MOUNTED_READ_ONLY.equals(state); if (!mounted) continue; final String rootId; final String title; if (storageVolume.isPrimary()) { rootId = ROOT_ID_PRIMARY_EMULATED; title = getContext().getString(R.string.root_internal_storage); } else if (storageVolume.getUuid() != null) { rootId = ROOT_ID_SECONDARY + storageVolume.getUuid(); String label = storageVolume.getUserLabel(); title = !TextUtils.isEmpty(label) ? label : getContext().getString(R.string.root_external_storage) + (count > 0 ? " " + count : ""); count++; } else { Log.d(TAG, "Missing UUID for " + storageVolume.getPath() + "; skipping"); continue; } if (mRoots.containsKey(rootId)) { Log.w(TAG, "Duplicate UUID " + rootId + "; skipping"); continue; } try { if(null == path.listFiles()){ continue; } final RootInfo root = new RootInfo(); mRoots.put(rootId, root); root.rootId = rootId; root.flags = Root.FLAG_SUPPORTS_CREATE | Root.FLAG_SUPPORTS_EDIT | Root.FLAG_LOCAL_ONLY | Root.FLAG_ADVANCED | Root.FLAG_SUPPORTS_SEARCH | Root.FLAG_SUPPORTS_IS_CHILD; root.title = title; root.path = path; root.docId = getDocIdForFile(path); } catch (FileNotFoundException e) { throw new IllegalStateException(e); } } }
Android 6 SdCard Path
最新推荐文章于 2021-10-13 11:48:44 发布