Back to project page silent-meeting.
The source code is released under:
GNU General Public License
If you think the Android project silent-meeting listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package uk.co.bensproule.silentmeeting.dao; /* www. j ava 2 s. c o m*/ import android.content.Context; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; import android.provider.CalendarContract.Events; import android.provider.CalendarContract.Instances; public class SQLiteHelper extends SQLiteOpenHelper { public static final int DATABASE_VERSION = 3; public static final String DATABASE_NAME = "SilentMeeting.db"; public static final String EVENTS_TABLE_NAME = "events"; public static final String INSTANCES_TABLE_NAME = "instances"; public static final String RUNNING = "running"; private static final String SQL_CREATE_EVENTS = "CREATE TABLE " + EVENTS_TABLE_NAME + " (" + Events._ID + " INTEGER PRIMARY KEY," + Events.CALENDAR_ID + " INTEGER," + Events.TITLE + " TEXT," + Events.DTSTART + " LONG," + Events.DTEND + " LONG," + Events.AVAILABILITY + " INTEGER," + Events.ORGANIZER + " TEXT)"; private static final String SQL_CREATE_INSTANCES = "CREATE TABLE " + INSTANCES_TABLE_NAME + " (" + Instances._ID + " INTEGER PRIMARY KEY," + Instances.EVENT_ID + " INTEGER," + Instances.TITLE + " TEXT," + Instances.BEGIN + " LONG," + Instances.END + " LONG," + Instances.AVAILABILITY + " INTEGER," + Instances.ORGANIZER + " TEXT," + RUNNING + " INTEGER)"; private static final String SQL_DELETE_EVENTS = "DROP TABLE IF EXISTS " + EVENTS_TABLE_NAME; private static final String SQL_DELETE_INSTANCES = "DROP TABLE IF EXISTS " + INSTANCES_TABLE_NAME; static SQLiteHelper sqLiteHelper; public SQLiteHelper(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); } public static SQLiteHelper instance(Context context) { if (sqLiteHelper == null) { sqLiteHelper = new SQLiteHelper(context); } return sqLiteHelper; } @Override public void onCreate(SQLiteDatabase db) { db.execSQL(SQL_CREATE_EVENTS); db.execSQL(SQL_CREATE_INSTANCES); } @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { db.execSQL(SQL_DELETE_EVENTS); db.execSQL(SQL_DELETE_INSTANCES); onCreate(db); } @Override public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) { onUpgrade(db, oldVersion, newVersion); } }