package com.hanju.video.app.util;
|
|
import java.lang.reflect.Method;
|
|
import android.app.Activity;
|
import android.content.Context;
|
import android.os.storage.StorageManager;
|
|
public class StorageList {
|
private Context context;
|
private StorageManager mStorageManager;
|
private Method mMethodGetPaths;
|
|
public StorageList(Context context) {
|
this.context = context;
|
if (context != null) {
|
mStorageManager = (StorageManager) context
|
.getSystemService(Activity.STORAGE_SERVICE);
|
try {
|
mMethodGetPaths = mStorageManager.getClass().getMethod(
|
"getVolumePaths");
|
} catch (NoSuchMethodException e) {
|
e.printStackTrace();
|
}
|
}
|
}
|
|
public String[] getVolumePaths() {
|
String[] paths = null;
|
try {
|
|
paths = (String[]) mMethodGetPaths.invoke(mStorageManager);
|
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
// catch (IllegalAccessException e) {
|
// e.printStackTrace();
|
// } catch (InvocationTargetException e) {
|
// e.printStackTrace();
|
// } catch (Exception e) {
|
// e.printStackTrace();
|
// }
|
return paths;
|
}
|
}
|