Uri mImageUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI; ContentResolver mContentResolver = ImageGridActivity.this.getContentResolver(); // 只查询jpeg和png的图片 Cursor mCursor = mContentResolver.query(mImageUri, null, MediaStore.Images.Media.MIME_TYPE + "=? or " + MediaStore.Images.Media.MIME_TYPE + "=?", new String[]{"image/jpeg", "image/png"}, MediaStore.Images.Media.DATE_MODIFIED); while (mCursor.moveToNext()) { // 获取图片的路径 String path = mCursor.getString(mCursor .getColumnIndex(MediaStore.Images.Media.DATA)); //imageItem.imageId = mCursor.getString(mCursor.getColumnIndex(MediaStore.Images.Media._ID)); Log.i("tag", mCursor.getPosition() + ":sd卡图片路径:" + path); }
获取到的路径类型:
1:
String path="/storage/sdcard0/Pictures/Screenshots/Screenshot_2016-10-08-17-00-11.png";
2:
String path="/storage/sdcard0/DCIM/Camera/IMG_20161026_115725.jpg"
//Picasso 加载
Picasso.with(mContext).load(new File(path)).resize(100, 100).error(R.mipmap.loading_adapter_two).placeholder(R.mipmap.loading_adapter_two).into(iv);或
Picasso.with(mContext).load("file:///" + path).resize(100, 100).error(R.mipmap.loading_adapter_two).placeholder(R.mipmap.loading_adapter_two).into(iv);问题:有的手机,两种路径(1,2)都可加载显示出来,比如小米2S. 有的手机第二种路径(DCIM)图片加载不出,比如G1-E(一种手机型号)。求大神指点:。。。