录制的视频在我的其他活动中不可见,直到我重新启动平板电脑变压器



我创建了一个有很多活动的项目。一项活动是录制视频,该视频正常。我可以在我指定的文件夹中看到录制的视频,而无需重新启动平板电脑。

但是,当我尝试使用查询的其他活动中的其他活动中的其他活动中找到所有视频时,请参见下面的代码。然后,在重新启动平板电脑之前,我看不到录制的视频。在开始平板电脑之前,我可以看到旧录制的视频。我不明白这种奇怪的行为。

任何人都可以阐明这个问题吗?

谢谢。

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
        _cursor.moveToFirst();
        for (int i = 0; i < count; i++) {
            int id = _cursor.getInt(_columnIndex);
            //
            _videosId[i] = id;
            //
            _cursor.moveToNext();
            //
        }
    } catch (Exception ex) {
        showToast(ex.getMessage().toString());
    }
}

如果将文件存储在外部存储上,则需要使用MediaScannerConnectionMediaStore索引到该文件,例如:

MediaScannerConnection.scanFile(
  this, 
  new String[] {file.getAbsolutePath()}, 
  null, 
  new OnScanCompletedListener() {
     @Override
     public void onScanCompleted(String path, Uri uri) {
        // do something if you want
     }
  });

最新更新