Android获取视频文件列表

public ArrayList<HashMap<String, String>> getVideoList() {
	ArrayList<HashMap<String , String>> hashmapList = new ArrayList<HashMap<String,String>>() ;
	String[] columns = {MediaStore.Video.Media.TITLE, MediaStore.Video.Media.DATA};
	Cursor cursor = getContentResolver().query(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, columns, null, null, MediaStore.Video.Media.DEFAULT_SORT_ORDER);
	if (cursor == null) return hashmapList;

	if (cursor.moveToFirst()) {
		int titleIndex = cursor.getColumnIndex(MediaStore.Video.Media.TITLE);
		int dataIndex = cursor.getColumnIndex(MediaStore.Video.Media.DATA);
		do {
			String szTitle = cursor.getString(titleIndex);
			String szPath = cursor.getString(dataIndex);

			HashMap<String, String> hashMap = new HashMap<String, String>();
			hashMap.put(MediaStore.Video.Media.TITLE, szTitle);
			hashMap.put(MediaStore.Video.Media.DATA, szPath);
			hashmapList.add(hashMap);
		} while (cursor.moveToNext());
	}
	cursor.close();
	return hashmapList;
}

 

上一篇:Android 设置APN


下一篇:使用docker容器进行项目开发