public static String[] getStoragePaths() {
List<String> pathsList = new ArrayList<String>();
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.GINGERBREAD) {
File externalFolder = Environment.getExternalStorageDirectory();
if (externalFolder != null) {
pathsList.add(externalFolder.getAbsolutePath());
}
} else {
StorageManager storageManager = (StorageManager) mContext.getSystemService(Context.STORAGE_SERVICE);
try {
Method method = StorageManager.class.getDeclaredMethod("getVolumePaths");
method.setAccessible(true);
Object result = method.invoke(storageManager);
if (result != null && result instanceof String[]) {
String[] paths = (String[]) result;
StatFs statFs;
for (String path : paths) {
if (!TextUtils.isEmpty(path) && new File(path).exists()) {
statFs = new StatFs(path);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
if (statFs.getBlockCountLong() * statFs.getBlockSizeLong() != ) {
pathsList.add(path);
}
}else{
if (statFs.getBlockCount() * statFs.getBlockSize() != ) {
pathsList.add(path);
}
}
}
}
}
} catch (Exception e) {
File externalFolder = Environment.getExternalStorageDirectory();
if (externalFolder != null) {
pathsList.add(externalFolder.getAbsolutePath());
}
}
}
return pathsList.toArray(new String[pathsList.size()]);
}