标签:blog http io os ar java for 文件 sp
问题描述public List<LocalMp3> getListByLocal() { Cursor cursor = getContentResolver().query( MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, null, null, null, MediaStore.Audio.Media.DEFAULT_SORT_ORDER); List<LocalMp3> localMp3s = new ArrayList<LocalMp3>(); for (int i = 0; i < cursor.getCount(); i++) { LocalMp3 localMp3 = new LocalMp3(); cursor.moveToNext(); String title = cursor.getString(cursor .getColumnIndex(MediaStore.Audio.Media.TITLE)); String artist = cursor.getString(cursor .getColumnIndex(MediaStore.Audio.Media.ARTIST)); long duration = cursor.getLong(cursor .getColumnIndex(MediaStore.Audio.Media.DURATION)); String mp3url = cursor.getString(cursor .getColumnIndex(MediaStore.Audio.Media.DATA)); int isMusic = cursor.getInt(cursor .getColumnIndex(MediaStore.Audio.Media.IS_MUSIC)); // 判断是否音乐 if (isMusic != 0) { localMp3.setTitle(title); localMp3.setArtist(artist); localMp3.setDuration(duration); localMp3.setMp3url(mp3url); localMp3s.add(localMp3); } } return localMp3s; }
标签:blog http io os ar java for 文件 sp
原文地址:http://www.cnblogs.com/yiguobei99/p/4027528.html