piku piku - 1 year ago 89
Android Question

Recorded Video is not Visible in my other Activity untill I reboot my Tablet Asus Transformer

I have created a Project having many activities. One activity is to record the video, that is working fine. I can see the recorded video in my specified folder without restart my tablet.

But when I try to find all the videos in that folder in some other activity using query, see code below. Then I can't see my recorded video until I restart my tablet. I can see just old recorded videos before starting my tablet. I couldn't understand this strange behavior.

Can anyone put some light on this issue??


private void initVideosId() { // getting the videos id in Video Folder of SD Card
try {
// Here we set up a string array of the thumbnail ID column we want
// to get back
String[] proj = { _ID };
//Querying for the videos in VideoGallery folder of SD card
// Now we create the cursor pointing to the external thumbnail store
_cursor = managedQuery(_contentUri, proj, // Which columns to return
MEDIA_DATA + " like ? ", // WHERE clause; which rows to
// return (all rows)
new String[] { "%VideoGallery%" }, // WHERE clause selection
// arguments (none)
null); // Order-by clause (ascending by name)
int count = _cursor.getCount();
// We now get the column index of the thumbnail id
_columnIndex = _cursor.getColumnIndex(_ID);
// initialize
_videosId = new int[count];
// move position to first element
for (int i = 0; i < count; i++) {
int id = _cursor.getInt(_columnIndex);
_videosId[i] = id;
} catch (Exception ex) {


Answer Source

If you stored the file on external storage, you need to use MediaScannerConnection to get the MediaStore to index that file, such as:

  new String[] {file.getAbsolutePath()}, 
  new OnScanCompletedListener() {
     public void onScanCompleted(String path, Uri uri) {
        // do something if you want
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download