我有这行代码:
String[] projection = {MediaStore.Audio.Media._ID, MediaStore.Audio.Media.ARTIST,
MediaStore.Audio.Media.TITLE, MediaStore.Audio.Media.DATA,
MediaStore.Audio.Media.DISPLAY_NAME,MediaStore.Audio.Media.DURATION};
哪个应该可以,但是eclipse给了我一个错误:“令牌上的语法错误“;”,,预期”
这是我的代码的上半部分:
public class Main extends Activity implements OnClickListener
{
ListView lv;
static final int check = 1111;
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
lv = (ListView) findViewById(R.id.listView1);
Button b = (Button) findViewById(R.id.button1);
b.setOnClickListener(this);
}
Cursor cursor;
String selection = MediaStore.Audio.Media.IS_MUSIC + " != 0";
String[] projection = {MediaStore.Audio.Media._ID, MediaStore.Audio.Media.ARTIST, MediaStore.Audio.Media.TITLE, MediaStore.Audio.Media.DATA, MediaStore.Audio.Media.DISPLAY_NAME, MediaStore.Audio.Media.DURATION};
cursor = this.managedQuery(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, projection, selection, null, null);
private List<String> songs = new ArrayList<String>();
while(cursor.moveToNext())
{
songs.add(cursor.getString(0) + "||" + cursor.getString(1) + "||" + cursor.getString(2) + "||" + cursor.getString(3) + "||" + cursor.getString(4) + "||" + cursor.getString(5));
}