查询图片:
private void loadImageList() {String[] columns = new String[]{MediaStore.Images.Media._ID, // 编号MediaStore.Images.Media.TITLE, // 标题MediaStore.Images.Media.SIZE, // 文件大小MediaStore.Images.Media.DATA, // 文件路径};Cursor cursor = getContentResolver().query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,columns,"_size < 307200",null,"_size Desc");int count = 0;if (cursor != null) {while (cursor.moveToNext() && count < 6) {ImageInfo image = new ImageInfo();image.id = cursor.getLong(cursor.getColumnIndex(MediaStore.Images.Media._ID));image.name = cursor.getString(cursor.getColumnIndex(MediaStore.Images.Media.TITLE));image.size = cursor.getLong(cursor.getColumnIndex(MediaStore.Images.Media.SIZE));image.path = cursor.getString(cursor.getColumnIndex(MediaStore.Images.Media.DATA));count++;mImageList.add(image);}}}
所需权限:
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
案例代码