Back to project page FxExplorer.
The source code is released under:
Apache License
If you think the Android project FxExplorer listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package info.breezes.fxmanager; //from w ww .jav a 2 s . c o m import android.os.Environment; import android.os.storage.StorageManager; import java.lang.reflect.Method; import java.util.ArrayList; /** * Storage Tools * Created by admin on 2015/1/6. */ public class StorageTool { public static String getVolumeState(StorageManager manager, String s) { try { Method method = StorageManager.class.getMethod("getVolumeState", String.class); return (String) method.invoke(manager, s); } catch (Exception e) { e.printStackTrace(); } return null; } public static String[] getVolumes(StorageManager manager) { try { Method method = StorageManager.class.getMethod("getVolumePaths"); return (String[]) method.invoke(manager, (Object[])null); } catch (Exception e) { e.printStackTrace(); } return null; } public static String[] getMountedVolumes(StorageManager manager) { ArrayList<String> mVols = new ArrayList<>(); String[] vols = getVolumes(manager); for (String str : vols) { if (Environment.MEDIA_MOUNTED.equals(getVolumeState(manager, str))) { mVols.add(str); } } return mVols.toArray(new String[mVols.size()]); } }