I have been looking at this for the last hour and do not see the problem, can someone please let me know how this works? I am trying to make a table of songs in my database on my tablet and I cannot get it to work. I followed an online tutorial and have gotten this far. I keep getting this error:
table songs has no column named genre
My code is below. I have included the relevant classes and code. If you need more of my code please let me know in the comments.
private static final String SONG_ID = "id";
private static final String SONG_TITLE = "title";
private static final String SONG_ARTIST = "artist";
private static final String SONG_ALBUM = "album";
private static final String SONG_ARTWORK = "artwork";
private static final String SONG_R_DATE = "releaseDate";
private static final String SONG_GENRE = "genre";
public void onCreate(SQLiteDatabase db) {
String CREATE_CONTACTS_TABLE = "CREATE TABLE " + TABLE_SONGS + "("
+ SONG_ID + " INTEGER PRIMARY KEY," + SONG_TITLE + " TEXT,"
+ SONG_ARTIST + " TEXT" + SONG_ALBUM + " TEXT" +
SONG_ARTWORK + " TEXT" + SONG_R_DATE + " TEXT" +
SONG_GENRE + " TEXT" +")";
db.execSQL(CREATE_CONTACTS_TABLE);
}
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL("DROP TABLE IF EXISTS " + TABLE_SONGS);
onCreate(db);
}
public void addSong(Song song) {
SQLiteDatabase db = this.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(SONG_TITLE, song.getTitle());
values.put(SONG_ARTIST, song.getArtist());
values.put(SONG_ALBUM, song.getAlbum());
values.put(SONG_ARTWORK, song.getArtwork());
values.put(SONG_R_DATE, song.getReleaseDate());
values.put(SONG_GENRE, song.getGenre());
db.insert(TABLE_SONGS, null, values);
db.close();
}
Aucun commentaire:
Enregistrer un commentaire