查找全部多媒体文件。
public ArrayList<Map<String, String>> getData(){ ArrayList<Map<String, String>> data = new ArrayList<Map<String, String>>(); ContentResolver cr =mContext.getContentResolver(); Uri audio_uri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI; String[] columns = new String[] { MediaStore.Audio.Media.TITLE, MediaStore.Audio.Media.DATA }; // 要读的列名 条件是只要是muisc为真都查找处理 Cursor cursor = cr.query(audio_uri, columns, MediaStore.Audio.Media.IS_MUSIC+"=?", new String[]{String.valueOf(1)}, null); // 跟查询SQL一样了,除了第一个参数不同外.后面根据时长过滤小于10秒的文件 while (cursor.moveToNext()) { // 循环读取第一列,即文件路径,0列是标题 //System.out.println(cursor.getString(0) + "文件路径:" + cursor.getString(1)+" 格式:"+cursor.getString(2)); String filePath = cursor.getString(1); Map<String, String> map = new HashMap<String, String>(); map.put("file_path", filePath); map.put("file_name", cursor.getString(0)+FileHelper.getSuffix(filePath)); data.add(map); } cursor.close(); return data; }