Back to project page SoundScheduler.
The source code is released under:
GNU General Public License
If you think the Android project SoundScheduler listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
/* * Sound Scheduler/*w w w . j av a 2 s .c o m*/ * Copyright (C) 2013 Victor Kifer */ package com.victorkifer.SoundScheduler.database; import android.content.ContentValues; import android.content.Context; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; import com.victorkifer.SoundScheduler.entities.Rule; public class RulesDatabaseHelper extends SQLiteOpenHelper { private static final String DATABASE_NAME = "rules.db"; private static final int DATABASE_VERSION = 8; public static final String TABLE_RULES = "rules"; public static final String RULES_COLUMN_ID = "_id"; public static final String RULES_COLUMN_START = "start"; public static final String RULES_COLUMN_END = "end"; public static final String RULES_COLUMN_ACTIVE = "active"; public static final String RULES_COLUMN_APPLIED = "applied"; public static final String RULES_COLUMN_REPEAT = "repeat"; public static final String RULES_COLUMN_STATE_BEFORE = "beforestate"; public static final String RULES_COLUMN_STATE_TO_APPLY = "statetoapply"; private static final String RULES_DATABASE_CREATE = "CREATE TABLE " + TABLE_RULES + "(" + RULES_COLUMN_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + RULES_COLUMN_START + " INTEGER NOT NULL, " + RULES_COLUMN_END + " INTEGER NOT NULL, " + RULES_COLUMN_ACTIVE + " INTEGER, " + RULES_COLUMN_APPLIED + " INTEGER, " + RULES_COLUMN_REPEAT + " INTEGER, " + RULES_COLUMN_STATE_BEFORE + " INTEGER, " + RULES_COLUMN_STATE_TO_APPLY + " INTEGER" + ");"; public RulesDatabaseHelper(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); } @Override public void onCreate(SQLiteDatabase db) { db.execSQL(RULES_DATABASE_CREATE); ContentValues values = new ContentValues(); values.put(RULES_COLUMN_START, 0); values.put(RULES_COLUMN_END, 25200000); values.put(RULES_COLUMN_ACTIVE, 0); // repeat from monday to friday values.put(RULES_COLUMN_REPEAT, 31); values.put(RULES_COLUMN_APPLIED, 0); values.put(RULES_COLUMN_STATE_BEFORE, Rule.STATE_NULL); values.put(RULES_COLUMN_STATE_TO_APPLY, Rule.STATE_SILENT); db.insert(RulesDatabaseHelper.TABLE_RULES, null, values); } @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { db.execSQL("DROP TABLE IF EXISTS " + TABLE_RULES); onCreate(db); } }