Android refresh local album

Source: Internet
Author: User

From: http://www.cnblogs.com/lingyun1120/archive/2011/12/27/2303560.html

 

FoundProgramAfter saving the image to sdcard, the image cannot be found in the album. The image will appear only after the sdcard is reloaded;

After the original image is saved locally, you need to add the following to the notification album:CodeJust fine:

Uri localuri = URI. fromfile (imagefile );

Intent localintent = new intent (intent. action_media_scanner_scan_file, localuri );

Sendbroadcast (localintent );

Imagefile is the file object of an image;

Or

Contentvalues localcontentvalues = new contentvalues ();

Localcontentvalues. Put ("_ data", imagefile. tostring ());

Localcontentvalues. Put ("Description", "Save image ---");

Localcontentvalues. Put ("mime_type", "image/JPEG ");

Contentresolver localcontentresolver = getcontentresolver ();

Uri localuri = mediastore. Images. Media. external_content_uri;

Localcontentresolver. insert (localuri, localcontentvalues );

 

Below is my own method to refresh the root directory

Sendbroadcast (new intent (intent. action_media_mounted, Uri. parse ("file: //" + environment. getexternalstoragedirectory ())));

Related Article

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.