public void addSongToNowPlaying(ArchiveSongObj s) { db.execSQL( "INSERT INTO playlistSongsTbl(playlist_id,song_id,trackNum) " + "Select 0," + s.getID() + ",MAX(trackNum) " + "from playlistSongsTbl where playlist_id = 0"); }
public void setNowPlayingSongs(ArrayList<ArchiveSongObj> songs) { clearNowPlayingSongs(); if (songs.size() > 0) { StringBuilder sql = new StringBuilder(); sql.append("INSERT INTO playlistSongsTbl(playlist_id,song_id,trackNum)"); int index = 0; for (ArchiveSongObj s : songs) { sql.append("SELECT 0," + s.getID() + "," + index + " "); if (index < songs.size() - 1) { sql.append("UNION ALL "); index++; } } db.execSQL(sql.toString()); } }