您的位置:首页 > 其它

获取手机录音和视频和图片

2015-02-04 13:40 127 查看
private void getImageFile()

{

if(mList!=null){

mList.clear();

//mList.add(new ImageEntity());

}

mContentResolver=AllImageShowActivity.this.getContentResolver();

Cursor cursor=mContentResolver.query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, null, null, null,MediaStore.Video.DEFAULT_SORT_ORDER);

if (cursor.moveToFirst()) {

do {

// ID:MediaStore.Audio.Media._ID

int id = cursor.getInt(cursor

.getColumnIndexOrThrow(MediaStore.Images.Media._ID));

// 名称:MediaStore.Audio.Media.TITLE

String title = cursor.getString(cursor

.getColumnIndexOrThrow(MediaStore.Images.Media.TITLE));

// 路径:MediaStore.Audio.Media.DATA

String url = cursor.getString(cursor

.getColumnIndexOrThrow(MediaStore.Images.Media.DATA));

// 总播放时长:MediaStore.Audio.Media.DURATION

// int duration = cursor

// .getInt(cursor

// .getColumnIndexOrThrow(MediaStore.Images.Media.DURATION));

// 大小:MediaStore.Audio.Media.SIZE

int size = (int) cursor.getLong(cursor

.getColumnIndexOrThrow(MediaStore.Images.Media.SIZE));

ImageEntity entty = new ImageEntity();

entty.ID = id;

entty.title = title;

entty.filePath = url;

entty.size = size;

entty.flag="false";

mList.add(entty);

} while (cursor.moveToNext());

}

if (cursor != null) {

cursor.close();

cursor = null;

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: