Android how to get an SD card to specify a folder picture Uri Uri problem

Source: Internet
Author: User

============ Problem Description ============


String a= "file://" +environment.getexternalstoragedirectory (). GetPath () + "/dcim/camera/";
File Basefile = new file (A + "/dcim/camera/15.jpg");

Uri uri = uri.fromfile (basefile);
Uri uri = Uri.parse (a);
Read all images from SD card
Uri uri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
string[] projection = {mediastore.images.media._id,
MediaStore.Images.Media.DISPLAY_NAME,
MediaStore.Images.Media.DATA, MediaStore.Images.Media.SIZE};
String selection = MediaStore.Images.Media.MIME_TYPE + "=?";
String[] Selectionarg = {"Image/jpeg"};
Cursor mcursor = this.managedquery (URI, projection, selection,
Selectionarg, MediaStore.Images.Media.DATE_MODIFIED + "desc");
Imagelist.clear ();
if (mcursor! = null) {
Mcursor.movetofirst ();
while (mcursor.getposition ()! = Mcursor.getcount ()) {
ImageMap = new hashmap<string, string> ();
Imagemap.put (ImageID, mcursor.getstring (mcursor
. Getcolumnindex (mediastore.images.media._id)));
Imagemap.put (ImageName, mcursor.getstring (mcursor
. Getcolumnindex (MediaStore.Images.Media.DISPLAY_NAME)));
Imagemap.put (
Imageinfo,
" "
+ (Mcursor.getlong (mcursor
. Getcolumnindex (MediaStore.Images.Media.SIZE))/1024)
+ "KB");
Imagelist.add (IMAGEMAP);
Filenames.add (Mcursor.getstring (mcursor
. Getcolumnindex (MediaStore.Images.Media.DATA)));
Mcursor.movetonext ();
}
Mcursor.close ();
}


Read all images from SD card
Uri uri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;

This way to get all the pictures OK, but I changed to the designated SD Card folder path but not

String a= "file://" +environment.getexternalstoragedirectory (). GetPath () + "/dcim/camera/";
File Basefile = new file (A + "/dcim/camera/15.jpg");

Uri uri = uri.fromfile (basefile);
Uri uri = Uri.parse (a);
Have tried all not, do not know for Isaac, please danale hint under

============ Solution 1============


If it is a folder File.delete () will delete all files in its directory but the folder still exists ~ If it is not a folder directly deleted!

How Android obtains a picture Uri URI problem for a specified folder in an SD card

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.