获取SD卡 tf卡 内置外置存储卡路径名称 路径的方式

来源:互联网 发布:csgo 三线性优化 编辑:程序博客网 时间:2024/04/28 08:24

获取SD卡 tf卡 内置外置存储卡路径名称 路径的方式  

直接附上 例子 

http://download.csdn.net/detail/v587ge/8594391

还有一种读取外置TF的方法 

public String GetSDcardPath(Context context) {String mPath = null;if (mSDCardPath.length() == 0) {Method mMethodGetPaths = null;String[] strs = null;StorageManager mStorageManager;mStorageManager = (StorageManager) context.getSystemService(Activity.STORAGE_SERVICE);try {mMethodGetPaths = mStorageManager.getClass().getMethod("getVolumePaths");} catch (NoSuchMethodException e) {e.printStackTrace();}try {strs = (String[]) mMethodGetPaths.invoke(mStorageManager);} catch (IllegalAccessException e) {e.printStackTrace();} catch (IllegalArgumentException e) {e.printStackTrace();} catch (InvocationTargetException e) {e.printStackTrace();}if (strs[0].equals(Environment.MEDIA_MOUNTED)) {mPath = strs[0];Log.e("tag", "第0个有外部存储卡" + strs[0]);} else {mPath = strs[1];Log.e("tag", "第1个有外部存储卡" + strs[1]);}if (mPath != null) {mPath = mPath + "/xiaoerlang/tongBuDianDu/";mSDCardPath = mPath;File f = new File(mPath);if (f.exists()) {} else {f.mkdirs();}} else {return null;}}return mSDCardPath;}
这种方法读取就非常的慢 很耗时

0 0