【发布时间】:2019-03-14 13:30:23
【问题描述】:
我正在尝试从内部共享存储和 sd 卡中获取视频的文件路径。
我在内部共享存储和外部存储的随机文件夹中随机保存了视频。
public ArrayList<String> getVideosPath(Activity activity,Context context)
{
listOfAllImages = new ArrayList<String>();
Cursor cursor;
final String[] columns = {MediaStore.Video.Media.DATA, MediaStore.Video.Media._ID};
final String orderBy = MediaStore.Video.Media._ID;
//Stores all the images from the gallery in Cursor
cursor = getContentResolver().query(
MediaStore.Video.Media.EXTERNAL_CONTENT_URI, columns, null,
null, orderBy);
//Total number of images
int count = cursor.getCount();
//Create an array to store path to all the images
String[] arrPath = new String[count];
for (int i = 0; i < count; i++) {
cursor.moveToPosition(i);
int dataColumnIndex = cursor.getColumnIndex(MediaStore.Video.Media.DATA);
//Store the path of the image
arrPath[i] = cursor.getString(dataColumnIndex);
Bitmap thumb = ThumbnailUtils.createVideoThumbnail(arrPath[i],
MediaStore.Images.Thumbnails.MINI_KIND);
// BitmapFactory.Options options = new BitmapFactory.Options();
// options.inSampleSize = 4;
// Bitmap b = BitmapFactory.decodeFile(arrPath[i], options);
bitmap.add(thumb);
// drawimages_onvideo.add(thumb);
Log.i("PATH", arrPath[i]);
listOfAllImages.add(arrPath[i]);
}
虽然它从sd卡和手机存储中获取文件,但路径不同。
例如,有 2 个视频文件,一个在 android 存储中,一个在 sd 卡中,路径是
安卓存储:/storage/emulated/0/Movies/videoplay.mp4
和
sd卡:/storage/BBF7-A8D2/videos/videoplay.mp4
我得到了这 2 个文件,但显示给我的路径是:
/storage/emulated/0/Movies/videoplay.mp4
/storage/emulated/0/Movies/videoplay.mp4
怎么了?
【问题讨论】:
标签: filepath android-sdcard android-storage