public int insertSong(ArchiveSongObj song) { db.execSQL( "INSERT INTO songTbl(fileName,songTitle,show_id,isDownloaded,folderName) " + "SELECT '" + song.getFileName() + "','" + song.toString().replaceAll("'", "''") + "',show._id,'false','' " + "FROM showTbl show " + "WHERE show.showIdent = '" + song.getShowIdentifier() + "' " + "AND NOT EXISTS (SELECT 1 FROM songTbl song WHERE song.fileName = '" + song.getFileName() + "')"); Cursor cur = db.rawQuery( "Select _id as song_id from songTbl " + "where fileName = '" + song.getFileName() + "'", null); cur.moveToFirst(); int id = cur.getInt(cur.getColumnIndex(PLAYLISTSONG_SONG_KEY)); cur.close(); if (song.hasFolder()) { db.execSQL("Update songTbl set folderName = '" + song.getFolder() + "' where _id = " + id); } return id; }
public void setSongDownloading(ArchiveSongObj song, long id) { Logging.Log(LOG_TAG, "Start Downloading " + song.getFileName() + ": " + id); db.execSQL( "UPDATE songTbl " + "SET download_id = '" + id + "' WHERE fileName = '" + song.getFileName() + "'"); }
public boolean getSongIsDownloading(ArchiveSongObj song) { Logging.Log(LOG_TAG, "Get downloading status for " + song.getFileName()); Cursor cur = db.rawQuery( "Select count(1) as count from songTbl " + "where fileName = '" + song.getFileName() + "' and download_id is not null and isDownloaded = 'false'", null); cur.moveToFirst(); int count = cur.getInt(cur.getColumnIndex("count")); Logging.Log(LOG_TAG, "Result: " + count); cur.close(); return count > 0; }
public void setSongDeleted(ArchiveSongObj song) { db.execSQL( "UPDATE songTbl " + "SET isDownloaded = 'false', download_id = null " + "WHERE fileName = '" + song.getFileName() + "'"); }
public void insertKnownSongIntoPlaylist(int playlist_id, ArchiveSongObj song, int position) { if (playlist_id <= 0) { // Playlist not saved yet return; } db.execSQL( "INSERT INTO playlistSongsTbl(playlist_id,song_id,trackNum) " + "SELECT " + playlist_id + ",song._id," + position + " FROM songTbl song " + "WHERE song.fileName = '" + song.getFileName() + "'"); }