獲得使用SQLite查詢吸走,這裏是我的問題,採取MediaStore.Audio.Artist.Artist爲例,Android的ContentProvider的查詢條件問題
String[] projection={MediaStore.Audio.Artists._ID,MediaStore.Audio.Artists.ARTIST};
String selectionClause=MediaStore.Audio.Artists.ARTIST+" = ?";
String[] selectionArgs={"Artist1","Artist2"};
只想拿回匹配字符串「Artist1」的結果,並「Artist2」,但我得到像下面的錯誤,
Caused by: java.lang.IllegalArgumentException: Cannot bind argument at index 2 because the index is out of range. The statement has 1 parameters.
請告訴我這是什麼錯誤,正確的方法來做,謝謝!
感謝您的回答,但不幸的是跟着你回答,cursoradapter不會被調用,不知道爲什麼? – Leon
我不確定你的意思是「不被稱爲」。請確保您的查詢將返回有效的結果,然後逐步調試 –
抱歉,我的表達不是很清楚,我的意思是當使用ur的想法時,CursorAdapter的方法bindView將不會執行。我在bindView中設置了Log.e命令,並且發現Log.e未運行 – Leon