diff options
Diffstat (limited to 'src/ryuslash/org/dvdroid/SQLiteHelper.java')
-rw-r--r-- | src/ryuslash/org/dvdroid/SQLiteHelper.java | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/ryuslash/org/dvdroid/SQLiteHelper.java b/src/ryuslash/org/dvdroid/SQLiteHelper.java new file mode 100644 index 0000000..c2ec71e --- /dev/null +++ b/src/ryuslash/org/dvdroid/SQLiteHelper.java @@ -0,0 +1,47 @@ +package ryuslash.org.dvdroid; + +import android.content.Context; +import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteOpenHelper; +import android.util.Log; + +public class SQLiteHelper extends SQLiteOpenHelper +{ + public static final String TABLE_DVD = "dvd"; + public static final String COLUMN_ID = "id"; + public static final String COLUMN_TITLE = "title"; + public static final String COLUMN_WATCHED = "watched"; + public static final String COLUMN_WISHLIST = "wishlist"; + + private static final String DATABASE_NAME = "dvdroid.db"; + private static final int DATABASE_VERSION = 1; + + private static final String TABLE_DVD_CREATE = + "create table " + TABLE_DVD + " (" + + COLUMN_ID + " integer primary key autoincrement, " + + COLUMN_TITLE + " text not null, " + + COLUMN_WATCHED + " integer not null, " + + COLUMN_WISHLIST + " integer not null" + + ");"; + + public SQLiteHelper(Context context) + { + super(context, DATABASE_NAME, null, DATABASE_VERSION); + } + + @Override + public void onCreate(SQLiteDatabase database) + { + database.execSQL(TABLE_DVD_CREATE); + } + + @Override + public void onUpgrade(SQLiteDatabase db, int oldV, int newV) + { + Log.w(SQLiteHelper.class.getName(), + "Upgrading database from version " + oldV + " to " + + newV + ", whech will destroy all old data"); + db.execSQL("DROP TABLE IF EXISTS " + TABLE_DVD); + onCreate(db); + } +} |