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

获取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;


	}
这种方法读取就非常的慢 很耗时

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值