我想从我的
Android设备获取所有图像/照片/壁纸与图像保存路径.
我已经实现了从sdcard收集图像的代码,如下所示:
String[] mProjection = { MediaStore.Images.Media._ID,MediaStore.Images.Media.DATA }; mCursor = cr.query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,mProjection,null,MediaStore.Images.Media.DEFAULT_SORT_ORDER);
从上面的代码我只能从sdcard中检索图像.但如果图像在设备手机内存中可用,那么我该如何检索图像/照片/壁纸?
如果我使用INTERNAL_CONTENT_URI它不会返回wallapers info其他图像信息
请任何身体帮助我….
解决方法
试试这个答案,这将有效:
public static final int galLERY_CODE = 322; Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); startActivityForResult(Intent.createChooser( intent,"Select Picture"),galLERY_CODE); @Override protected void onActivityResult(int requestCode,int resultCode,Intent data) { //Assinging on corresponding import super.onActivityResult(requestCode,resultCode,data); if (requestCode == galLERY_CODE && resultCode == RESULT_OK) { Uri selectedImageUri = data.getData(); selectedImagePath = getPath(selectedImageUri); try { //add logic for coping file } catch (Exception e) { } } } public String getPath(Uri uri) { String[] projection = { MediaStore.Images.Media.DATA }; Cursor cursor = managedQuery(uri,projection,null); int column_index = cursor .getColumnIndexOrThrow(MediaStore.Images.Media.DATA); cursor.movetoFirst(); return cursor.getString(column_index); }