android - Access All Media Files on Internal Storage -
i'm using following example try load saved images , video on android device customized gallery activity:
access ordered images , video in same cursor
while works images , video created using default android camera app, doesn't seem find media files saved locally in folder app (located in pictures/name_of_app)
how can fetch media files on device?
private string[] projection = { mediastore.files.filecolumns._id, mediastore.files.filecolumns.data, mediastore.files.filecolumns.date_added, mediastore.files.filecolumns.media_type, mediastore.files.filecolumns.mime_type, mediastore.files.filecolumns.title }; // used query contentresolver mediafiles private string selection = mediastore.files.filecolumns.media_type + "=" + mediastore.files.filecolumns.media_type_image + " or " + mediastore.files.filecolumns.media_type + "=" + mediastore.files.filecolumns.media_type_video; // used select images , videos contentresolver private uri queryuri = mediastore.files.getcontenturi("external"); cl = new cursorloader(customizedgallery.this, queryuri, projection, selection, null, mediastore.files.filecolumns.date_added + " desc");
it sounds files haven't been added mediastore database yet. can check checking gallery app - if don't show there aren't in db yet.
simply creating them not automatically add them database - scans happen @ regular trigger points(such on reboot or remount of external storage) or can manually request rescan.
to request scan of particular file can call:
sendbroadcast(new intent(intent.action_media_scanner_scan_file, uri.fromfile(newfile)));
more information here: how can refresh mediastore on android?
Comments
Post a Comment