Android Open Source - MusicPlayer-OLD Playlists Database






From Project

Back to project page MusicPlayer-OLD.

License

The source code is released under:

Apache License

If you think the Android project MusicPlayer-OLD listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/*
 * Copyright 2012-2013 Andrea De Cesare/* w  ww  .j av  a2 s  .c  o  m*/
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.andreadec.musicplayer.database;

import com.andreadec.musicplayer.MusicPlayerApplication;
import android.database.sqlite.*;

public class PlaylistsDatabase extends SQLiteOpenHelper {
  private static final String DB_NAME = "Playlists";
  private static final int DB_VERSION = 3;
  
  public PlaylistsDatabase() {
    super(MusicPlayerApplication.getContext(), DB_NAME, null, DB_VERSION);
  }
  
  @Override
  public void onCreate(SQLiteDatabase db) {
    db.execSQL("CREATE TABLE Playlists (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, position INTEGER DEFAULT 0)");
    db.execSQL("CREATE TABLE SongsInPlaylist (idSong INTEGER, idPlaylist INTEGER, uri TEXT, artist TEXT, title TEXT, position INTEGER DEFAULT 0, hasImage INTEGER DEFAULT 1, PRIMARY KEY(idSong), FOREIGN KEY(idPlaylist) REFERENCES Playlists (id))");
  }

  @Override
  public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    if(oldVersion==1 && newVersion==2) from1to2(db);
    if(oldVersion==2 && newVersion==3) from2to3(db);
    if(oldVersion==1 && newVersion==3) {from1to2(db);from2to3(db);}
  }
  
  private void from1to2(SQLiteDatabase db) {
    db.execSQL("ALTER TABLE Playlists ADD position INTEGER DEFAULT 0");
    db.execSQL("ALTER TABLE SongsInPlaylist ADD position INTEGER DEFAULT 0");
  }
  
  private void from2to3(SQLiteDatabase db) {
    db.execSQL("ALTER TABLE SongsInPlaylist ADD hasImage INTEGER DEFAULT 1");
  }
}




Java Source Code List

com.andreadec.musicplayer.AboutActivity.java
com.andreadec.musicplayer.Action.java
com.andreadec.musicplayer.BrowserDirectory.java
com.andreadec.musicplayer.BrowserFragment.java
com.andreadec.musicplayer.BrowserSong.java
com.andreadec.musicplayer.Constants.java
com.andreadec.musicplayer.DirectoryChooserDialog.java
com.andreadec.musicplayer.ImageLoaderTask.java
com.andreadec.musicplayer.IndexFolderService.java
com.andreadec.musicplayer.Information.java
com.andreadec.musicplayer.MainActivity.java
com.andreadec.musicplayer.MusicPlayerApplication.java
com.andreadec.musicplayer.MusicPlayerFragment.java
com.andreadec.musicplayer.MusicService.java
com.andreadec.musicplayer.PlayableItem.java
com.andreadec.musicplayer.PlaylistFragment.java
com.andreadec.musicplayer.PlaylistSong.java
com.andreadec.musicplayer.Playlist.java
com.andreadec.musicplayer.Playlists.java
com.andreadec.musicplayer.PodcastEpisodeDownloaderService.java
com.andreadec.musicplayer.PodcastEpisode.java
com.andreadec.musicplayer.PodcastParser.java
com.andreadec.musicplayer.Podcast.java
com.andreadec.musicplayer.PodcastsFragment.java
com.andreadec.musicplayer.PreferencesActivity.java
com.andreadec.musicplayer.RadioFragment.java
com.andreadec.musicplayer.Radio.java
com.andreadec.musicplayer.SearchActivity.java
com.andreadec.musicplayer.ShakeListener.java
com.andreadec.musicplayer.Utils.java
com.andreadec.musicplayer.adapters.BrowserArrayAdapter.java
com.andreadec.musicplayer.adapters.MusicListArrayAdapter.java
com.andreadec.musicplayer.adapters.NavigationDrawerArrayAdapter.java
com.andreadec.musicplayer.adapters.PlaylistArrayAdapter.java
com.andreadec.musicplayer.adapters.PodcastsArrayAdapter.java
com.andreadec.musicplayer.adapters.RadioArrayAdapter.java
com.andreadec.musicplayer.adapters.SearchResultsArrayAdapter.java
com.andreadec.musicplayer.comparators.BrowserSongsComparator.java
com.andreadec.musicplayer.comparators.PlaylistsComparator.java
com.andreadec.musicplayer.database.PlaylistsDatabase.java
com.andreadec.musicplayer.database.PodcastsDatabase.java
com.andreadec.musicplayer.database.RadiosDatabase.java
com.andreadec.musicplayer.database.SongsDatabase.java
com.andreadec.musicplayer.filters.AudioFileFilter.java
com.andreadec.musicplayer.filters.DirectoryFilter.java