a我在显示 SD 卡文件夹中的所有视频时遇到问题。目前,我能够显示 SD 卡中可以找到的所有视频,但我想做的是显示 SD 卡内“PartyVideo”文件夹中的所有视频。你能帮我吗?下面是我在 SD 卡中显示所有视频的代码。
final String[] columns = { MediaStore.Video.Media.DATA, MediaStore.Video.Media._ID };
final String orderBy = MediaStore.Video.Media.DATE_TAKEN;
Cursor imagecursor = managedQuery(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, columns, null,null, orderBy + " DESC");
int image_column_index = imagecursor.getColumnIndex(MediaStore.Video.Media._ID);
this.count = imagecursor.getCount();
this.thumbnails = new Bitmap[this.count];
this.arrPath = new String[this.count];
this.thumbnailsselection = new boolean[this.count];
for (int i = 0; i < this.count; i++)
{
imagecursor.moveToPosition(i);
int id = imagecursor.getInt(image_column_index);
int dataColumnIndex = imagecursor.getColumnIndex(MediaStore.Video.Media.DATA);
thumbnails[i] = MediaStore.Video.Thumbnails.getThumbnail(
getApplicationContext().getContentResolver(), id,
MediaStore.Video.Thumbnails.MICRO_KIND, null);
arrPath[i]= imagecursor.getString(dataColumnIndex);
}
GridView imagegrid = (GridView) findViewById(R.id.grid_GalleryImage);
imageAdapter = new ImageAdapter();
imagegrid.setAdapter(imageAdapter);
我尝试了许多不同的代码,最后得到了这个。下面的代码在我想要的文件夹中获取所有视频,但我不知道如何显示它。
String[] fileList = null;
File videoFiles = new File(Environment.getExternalStorageDirectory()+"/PartyVideo");
if(videoFiles.isDirectory())
{
fileList=videoFiles.list();
}
for(int i=0;i<fileList.length;i++)
{
Log.e("Video:"+i+" File name",fileList[i]);
}