List of usage examples for android.os.storage StorageManager getVolumeState
@Deprecated
@UnsupportedAppUsage
public @NonNull String getVolumeState(String mountPoint)
From source file:com.mediatek.contacts.activities.ActivitiesUtils.java
private static int getAvailableStorageCount(Activity activity) { int storageCount = 0; final StorageManager storageManager = (StorageManager) activity.getApplicationContext() .getSystemService(activity.STORAGE_SERVICE); if (null == storageManager) { Log.w(TAG, "[getAvailableStorageCount]storageManager is null,return 0."); return 0; }//from w w w . ja v a2 s .co m StorageVolume[] volumes = storageManager.getVolumeList(); for (StorageVolume volume : volumes) { String path = volume.getPath(); if (!Environment.MEDIA_MOUNTED.equals(storageManager.getVolumeState(path))) { continue; } storageCount++; } Log.d(TAG, "[getAvailableStorageCount]storageCount = " + storageCount); return storageCount; }
From source file:com.android.mms.ui.MessageUtils.java
public static boolean existingSD(Context context, boolean isExternal) { StorageManager mStorageMamatger; mStorageMamatger = (StorageManager) context.getSystemService(Context.STORAGE_SERVICE); StorageVolume[] volumes = mStorageMamatger.getVolumeList(); if (volumes == null) { return false; }/*www . j a v a 2 s . c o m*/ String mountPoint = null; for (int i = 0; i < volumes.length; i++) { if (isExternal) { if (volumes[i].isRemovable()) { mountPoint = volumes[i].getPath(); break; } } else { if (!volumes[i].isRemovable()) { mountPoint = volumes[i].getPath(); break; } } } if (mountPoint == null) { return false; } String volumeState = mStorageMamatger.getVolumeState(mountPoint); return (volumeState != null && volumeState.equals(Environment.MEDIA_MOUNTED)); }