Android Open Source - HelloMundo Hello Mundo S Q Lite Open Helper






From Project

Back to project page HelloMundo.

License

The source code is released under:

GNU General Public License

If you think the Android project HelloMundo 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

/*
 * This source is part of the//from  w  w  w .  j  a  v a  2 s.  c  om
 *      _____  ___   ____
 *  __ / / _ \/ _ | / __/___  _______ _
 * / // / , _/ __ |/ _/_/ _ \/ __/ _ `/
 * \___/_/|_/_/ |_/_/ (_)___/_/  \_, /
 *                              /___/
 * repository.
 *
 * Copyright (C) 2009-2014 Benoit 'BoD' Lubek (BoD@JRAF.org)
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package org.jraf.android.hellomundo.provider;

import android.annotation.TargetApi;
import android.content.Context;
import android.database.DatabaseErrorHandler;
import android.database.DefaultDatabaseErrorHandler;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;
import android.os.Build;
import android.util.Log;

import org.jraf.android.hellomundo.provider.appwidget.AppwidgetColumns;
import org.jraf.android.hellomundo.provider.webcam.WebcamColumns;
import org.jraf.android.latoureiffel.BuildConfig;

public class HelloMundoSQLiteOpenHelper extends SQLiteOpenHelper {
    private static final String TAG = HelloMundoSQLiteOpenHelper.class.getSimpleName();

    public static final String DATABASE_FILE_NAME = "worldtour.db";
    private static final int DATABASE_VERSION = 2;

    // @formatter:off
    private static final String SQL_CREATE_TABLE_APPWIDGET = "CREATE TABLE IF NOT EXISTS "
            + AppwidgetColumns.TABLE_NAME + " ( "
            + AppwidgetColumns._ID + " INTEGER PRIMARY KEY AUTOINCREMENT, "
            + AppwidgetColumns.APPWIDGET_ID + " INTEGER NOT NULL, "
            + AppwidgetColumns.WEBCAM_ID + " INTEGER NOT NULL, "
            + AppwidgetColumns.CURRENT_WEBCAM_ID + " INTEGER "
            + " );";

    private static final String SQL_CREATE_TABLE_WEBCAM = "CREATE TABLE IF NOT EXISTS "
            + WebcamColumns.TABLE_NAME + " ( "
            + WebcamColumns._ID + " INTEGER PRIMARY KEY AUTOINCREMENT, "
            + WebcamColumns.TYPE + " INTEGER NOT NULL, "
            + WebcamColumns.PUBLIC_ID + " TEXT, "
            + WebcamColumns.NAME + " TEXT NOT NULL, "
            + WebcamColumns.LOCATION + " TEXT, "
            + WebcamColumns.URL + " TEXT NOT NULL, "
            + WebcamColumns.THUMB_URL + " TEXT, "
            + WebcamColumns.SOURCE_URL + " TEXT, "
            + WebcamColumns.HTTP_REFERER + " TEXT, "
            + WebcamColumns.TIMEZONE + " TEXT, "
            + WebcamColumns.RESIZE_WIDTH + " INTEGER, "
            + WebcamColumns.RESIZE_HEIGHT + " INTEGER, "
            + WebcamColumns.VISIBILITY_BEGIN_HOUR + " INTEGER, "
            + WebcamColumns.VISIBILITY_BEGIN_MIN + " INTEGER, "
            + WebcamColumns.VISIBILITY_END_HOUR + " INTEGER, "
            + WebcamColumns.VISIBILITY_END_MIN + " INTEGER, "
            + WebcamColumns.ADDED_DATE + " INTEGER NOT NULL, "
            + WebcamColumns.EXCLUDE_RANDOM + " INTEGER, "
            + WebcamColumns.COORDINATES + " TEXT "
            + " );";

    private static final String SQL_UPDATE_TABLE_APPWIDGET_2  = "ALTER TABLE "
            + AppwidgetColumns.TABLE_NAME + " "
            + "ADD COLUMN " + AppwidgetColumns.CURRENT_WEBCAM_ID + " TEXT "
            + " ;";
    
    // @formatter:on

    public static HelloMundoSQLiteOpenHelper newInstance(Context context) {
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
            return newInstancePreHoneycomb(context);
        }
        return newInstancePostHoneycomb(context);
    }


    /*
     * Pre Honeycomb.
     */

    private static HelloMundoSQLiteOpenHelper newInstancePreHoneycomb(Context context) {
        return new HelloMundoSQLiteOpenHelper(context, DATABASE_FILE_NAME, null, DATABASE_VERSION);
    }

    private HelloMundoSQLiteOpenHelper(Context context, String name, CursorFactory factory, int version) {
        super(context, name, factory, version);
    }


    /*
     * Post Honeycomb.
     */

    @TargetApi(Build.VERSION_CODES.HONEYCOMB)
    private static HelloMundoSQLiteOpenHelper newInstancePostHoneycomb(Context context) {
        return new HelloMundoSQLiteOpenHelper(context, DATABASE_FILE_NAME, null, DATABASE_VERSION, new DefaultDatabaseErrorHandler());
    }

    @TargetApi(Build.VERSION_CODES.HONEYCOMB)
    private HelloMundoSQLiteOpenHelper(Context context, String name, CursorFactory factory, int version, DatabaseErrorHandler errorHandler) {
        super(context, name, factory, version, errorHandler);
    }


    @Override
    public void onCreate(SQLiteDatabase db) {
        if (BuildConfig.DEBUG) Log.d(TAG, "onCreate");
        db.execSQL(SQL_CREATE_TABLE_APPWIDGET);
        db.execSQL(SQL_CREATE_TABLE_WEBCAM);
    }


    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        if (BuildConfig.DEBUG) Log.d(TAG, "Upgrading database from version " + oldVersion + " to " + newVersion);
        if (newVersion == 2) {
            db.execSQL(SQL_UPDATE_TABLE_APPWIDGET_2);
        }
    }
}




Java Source Code List

org.jraf.android.hellomundo.Config.java
org.jraf.android.hellomundo.Config.java
org.jraf.android.hellomundo.Constants.java
org.jraf.android.hellomundo.analytics.AnalyticsHelper.java
org.jraf.android.hellomundo.app.Application.java
org.jraf.android.hellomundo.app.about.AboutActivity.java
org.jraf.android.hellomundo.app.about.EulaActivity.java
org.jraf.android.hellomundo.app.adduserwebcam.AddUserWebcamActivity.java
org.jraf.android.hellomundo.app.appwidget.refresh.RefreshAppWidgetProvider.java
org.jraf.android.hellomundo.app.appwidget.webcam.WebcamAppWidgetActionsActivity.java
org.jraf.android.hellomundo.app.appwidget.webcam.WebcamAppWidgetProvider3x3.java
org.jraf.android.hellomundo.app.appwidget.webcam.WebcamAppWidgetProvider.java
org.jraf.android.hellomundo.app.appwidget.webcam.WebcamConfigureActivity.java
org.jraf.android.hellomundo.app.common.BaseActivity.java
org.jraf.android.hellomundo.app.common.BasePreferenceActivity.java
org.jraf.android.hellomundo.app.main.MainActivity.java
org.jraf.android.hellomundo.app.pickwebcam.PickWebcamActivity.java
org.jraf.android.hellomundo.app.pickwebcam.PickWebcamListFragment.java
org.jraf.android.hellomundo.app.pickwebcam.PreviewDialogFragment.java
org.jraf.android.hellomundo.app.pickwebcam.WebcamAdapter.java
org.jraf.android.hellomundo.app.pickwebcam.WebcamCallbacks.java
org.jraf.android.hellomundo.app.preference.PreferenceActivity.java
org.jraf.android.hellomundo.app.receiver.BootCompletedBroadcastReceiver.java
org.jraf.android.hellomundo.app.receiver.WallpaperChangedBroadcastReceiver.java
org.jraf.android.hellomundo.app.saveshare.SaveShareHelper.java
org.jraf.android.hellomundo.app.saveshare.SaveShareListener.java
org.jraf.android.hellomundo.app.service.HelloMundoService.java
org.jraf.android.hellomundo.app.welcome.WelcomeActivity.java
org.jraf.android.hellomundo.model.AppwidgetManager.java
org.jraf.android.hellomundo.model.WebcamInfo.java
org.jraf.android.hellomundo.model.WebcamManager.java
org.jraf.android.hellomundo.provider.HelloMundoProvider.java
org.jraf.android.hellomundo.provider.HelloMundoSQLiteOpenHelper.java
org.jraf.android.hellomundo.provider.appwidget.AppwidgetColumns.java
org.jraf.android.hellomundo.provider.appwidget.AppwidgetContentValues.java
org.jraf.android.hellomundo.provider.appwidget.AppwidgetCursor.java
org.jraf.android.hellomundo.provider.appwidget.AppwidgetSelection.java
org.jraf.android.hellomundo.provider.base.AbstractContentValues.java
org.jraf.android.hellomundo.provider.base.AbstractCursor.java
org.jraf.android.hellomundo.provider.base.AbstractSelection.java
org.jraf.android.hellomundo.provider.webcam.WebcamColumns.java
org.jraf.android.hellomundo.provider.webcam.WebcamContentValues.java
org.jraf.android.hellomundo.provider.webcam.WebcamCursor.java
org.jraf.android.hellomundo.provider.webcam.WebcamSelection.java
org.jraf.android.hellomundo.provider.webcam.WebcamType.java