0
我正在執行對mediastore的查詢,以努力返回特定atist的專輯數量。查詢MediaStore - SQLiteException
查詢看起來是這樣的:
public String doQuery(String artistName) {
String[] proj = new String[] { MediaStore.Audio.Artists._ID,
MediaStore.Audio.Artists.NUMBER_OF_ALBUMS,
MediaStore.Audio.Artists.ARTIST };
Uri baseUri = MediaStore.Audio.Artists.EXTERNAL_CONTENT_URI;
selection = MediaStore.Audio.Artists.ARTIST + " = " + artistName;
Log.i(TAG, "Selection artistName = " + artistName);
Cursor mCursor = getContentResolver().query(baseUri, proj, selection,
null, null);
mCursor.moveToFirst();
return
mCursor.getString(mCursor
.getColumnIndex(MediaStore.Audio.Artists.NUMBER_OF_ALBUMS));
}
的ARTISTNAME傳遞中,並且選擇應該向下縮小光標只有藝術家。我收到以下例外情況:
09-19 23:13:14.855: E/AndroidRuntime(17911): android.database.sqlite.SQLiteException: near "Stone": syntax error (code 1): , while compiling: SELECT _id, number_of_albums, artist FROM artist_info WHERE (artist = Nine Inch Nails)
有人可以告訴我我做錯了什麼嗎?