Android Open Source - piRSS D B






From Project

Back to project page piRSS.

License

The source code is released under:

GNU General Public License

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

/**
 * Copyright (C) 2011 Matthias Jordan <matthias.jordan@googlemail.com>
 */*from w  w  w  . j a  va  2  s  .  c  om*/
 * This file is part of piRSS.
 *
 * piRSS 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.
 *
 * piRSS 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 piRSS.  If not, see <http://www.gnu.org/licenses/>.
 */
package de.codefu.android.rss.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;



/**
 * Basic database access.
 * 
 * @author mj
 */
class DB extends SQLiteOpenHelper {

    /**
     * The package name. Used for intents.
     */
    public static final String PACKAGE_NAME = DB.class.getPackage().getName();
    /**
     * The intent name for the "data has changed" intent.
     */
    public static final String DATA_CHANGED = PACKAGE_NAME + "action.datachanged";
    /**
     * The database name.
     */
    private static final String DB_NAME = "rssdb";
    /**
     * The version of the database schema. Increase if the schema has changed
     * and an upgrade step has to be triggered.
     */
    private static final int DB_VERSION = 3;
    /**
     * Reference to the context.
     */
    private Context context;
    /**
     * Reference to the singleton instance.
     */
    private static volatile DB INSTANCE = null;


    private DB(Context context) {
        super(context, DB_NAME, null, DB_VERSION);
        this.context = context;
    }


    /**
     * Returns the singleton's instance.
     * 
     * @param context
     *            the context - only needed at the first call
     * @return the instance
     */
    public static synchronized DB getInstance(Context context) {
        if (INSTANCE == null) {
            INSTANCE = new DB(context);
        }
        return INSTANCE;
    }


    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL(FeedProvider.getCreateTable());
        db.execSQL(ItemProvider.getCreateTable());
        db.execSQL(ItemProvider.getCreateTmpTable());
        db.execSQL(ItemProvider.getCreateAuxTable());
        FeedProvider.addDefaultFeed(context, db);
    }


    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        if ((oldVersion == 2) && (newVersion == 3)) {
            db.execSQL("alter table " + ItemProvider.ITEMS_NAME + " add column " + ItemProvider.ITEMS_COL_KEEPER
                            + " INTEGER");
        }
    }

}




Java Source Code List

de.codefu.android.rss.AboutActivity.java
de.codefu.android.rss.BootCompletedHandler.java
de.codefu.android.rss.CursorChangedReceiver.java
de.codefu.android.rss.MainPreferences.java
de.codefu.android.rss.UserNotification.java
de.codefu.android.rss.db.DB.java
de.codefu.android.rss.db.FeedProvider.java
de.codefu.android.rss.db.ItemHelper.java
de.codefu.android.rss.db.ItemProvider.java
de.codefu.android.rss.db.UriHelper.java
de.codefu.android.rss.feedlist.FeedListAdapter.java
de.codefu.android.rss.feedlist.FeedList.java
de.codefu.android.rss.feedprops.AddFeed.java
de.codefu.android.rss.feedprops.FeedProps.java
de.codefu.android.rss.item.ItemAct.java
de.codefu.android.rss.itemlist.ItemListAdapter.java
de.codefu.android.rss.itemlist.ItemList.java
de.codefu.android.rss.updateservice.AutoPollService.java
de.codefu.android.rss.updateservice.DateFormat3339.java
de.codefu.android.rss.updateservice.FeedHandlerClient.java
de.codefu.android.rss.updateservice.FeedHandler.java
de.codefu.android.rss.updateservice.InsertService.java
de.codefu.android.rss.updateservice.ServiceComm.java
de.codefu.android.rss.updateservice.UpdateService.java
de.codefu.android.rss.updateservice.UrlHttpRetriever.java
de.codefu.android.rss.updateservice.Utils.java
de.codefu.android.rss.updateservice.WakeLockHolder.java
de.codefu.android.rss.widgets.SimpleWidget.java