Android Open Source - silent-meeting S Q Lite Helper






From Project

Back to project page silent-meeting.

License

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.

Java Source Code

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);
    }
}




Java Source Code List

uk.co.bensproule.silentmeeting.ApplicationTest.java
uk.co.bensproule.silentmeeting.activity.PreferencesActivity.java
uk.co.bensproule.silentmeeting.constants.Actions.java
uk.co.bensproule.silentmeeting.constants.Extra.java
uk.co.bensproule.silentmeeting.constants.Setting.java
uk.co.bensproule.silentmeeting.dao.EventDao.java
uk.co.bensproule.silentmeeting.dao.InstanceDao.java
uk.co.bensproule.silentmeeting.dao.SQLiteHelper.java
uk.co.bensproule.silentmeeting.domain.Attendee.java
uk.co.bensproule.silentmeeting.domain.Calendar.java
uk.co.bensproule.silentmeeting.domain.DialogCloseListener.java
uk.co.bensproule.silentmeeting.domain.Event.java
uk.co.bensproule.silentmeeting.domain.Instance.java
uk.co.bensproule.silentmeeting.fragment.TimePickerFragment.java
uk.co.bensproule.silentmeeting.receiver.CalendarEventsReceiver.java
uk.co.bensproule.silentmeeting.receiver.MutePhoneBroadcastReceiver.java
uk.co.bensproule.silentmeeting.receiver.UnmutePhoneBroadcastReceiver.java
uk.co.bensproule.silentmeeting.util.StringUtils.java