int getIdForSong(Song song){
String selectQuery = "SELECT id FROM " + TABLE_SONG + " WHERE " + SONG_TITLE + "=" + song.getSongTitle() + " AND " + ARTIST_NAME + "=" + song.getArtistName();
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.rawQuery(selectQuery, null);
int id = Integer.parseInt(cursor.getString(0));
return id;
}
我越來越接近「=」例外。任何人?以下selectQuery有什麼問題嗎?
你已經給你的' 「=」'取代' 「=」「'看看[this](http://www.vogella.com/articles/AndroidSQLite/article.html#sqliteoverview_rawquery) – Praveenkumar
也int id = Integer.parseInt(cursor.getString(0));拋出CursorOutOfBoundIndex ..我不知道爲什麼,因爲ID應該返回在getString(0)作爲id字段是主鍵自動增量。 – Saurabh