Android Open Source - SandB-Android Article Storage Helper






From Project

Back to project page SandB-Android.

License

The source code is released under:

GNU General Public License

If you think the Android project SandB-Android 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 edu.grinnell.sandb.data;
//from   w ww .  ja v a 2  s.c  o m
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

public class ArticleStorageHelper extends SQLiteOpenHelper {

  public static final String TABLE_ARTICLES = "articles";
  public static final String COLUMN_ID = "_id";
  public static final String COLUMN_CATEGORY = "category";
  public static final String COLUMN_GUID = "guid";
  public static final String COLUMN_TITLE = "title";
  public static final String COLUMN_LINK = "link";
  public static final String COLUMN_PUBDATE = "pubdate";
  public static final String COLUMN_DESCRIPTION = "description";
  public static final String COLUMN_BODY = "body";
  public static final String COLUMN_COMMENTS = "comments";
  public static final String COLUMN_AUTHOR = "author";


  private static final String DATABASE_NAME = "articles.db";
  private static final int DATABASE_VERSION = 7;

  // Database creation sql statement
  public static final String DATABASE_CREATE = "create table "
      + TABLE_ARTICLES + "(" + COLUMN_ID
      + " integer primary key autoincrement, " 
      + COLUMN_CATEGORY + " text, " 
      + COLUMN_GUID + " text, "
      + COLUMN_TITLE + " text not null, "
      + COLUMN_LINK + " text, "
      + COLUMN_PUBDATE + " text, "
      + COLUMN_DESCRIPTION + " text, " 
      + COLUMN_BODY + " text not null, "
      + COLUMN_COMMENTS + " text, "
      + COLUMN_AUTHOR + " text"
      + ");";

  public ArticleStorageHelper(Context context) {
    super(context, DATABASE_NAME, null, DATABASE_VERSION);
  }

  @Override
  public void onCreate(SQLiteDatabase db) {
    db.execSQL(DATABASE_CREATE);
  }

  @Override
  public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    Log.w(ArticleStorageHelper.class.getName(),
            "Upgrading database from version " + oldVersion + " to "
                + newVersion + ", which will destroy all old data");
        db.execSQL("DROP TABLE IF EXISTS " + TABLE_ARTICLES);
        onCreate(db);
  }

}




Java Source Code List

edu.grinnell.sandb.ArticleDetailActivity.java
edu.grinnell.sandb.ArticleDetailFragment.java
edu.grinnell.sandb.ArticleListAdapter.java
edu.grinnell.sandb.ArticleListFragment.java
edu.grinnell.sandb.CommentListAdapter.java
edu.grinnell.sandb.CommentListFragment.java
edu.grinnell.sandb.ImagePagerActivity.java
edu.grinnell.sandb.MainActivity.java
edu.grinnell.sandb.MainPrefs.java
edu.grinnell.sandb.ScarletAndBlackApplication.java
edu.grinnell.sandb.Utility.java
edu.grinnell.sandb.comments.CommentStorageHelper.java
edu.grinnell.sandb.comments.CommentTable.java
edu.grinnell.sandb.comments.Comment.java
edu.grinnell.sandb.data.ArticleStorageHelper.java
edu.grinnell.sandb.data.ArticleTable.java
edu.grinnell.sandb.data.Article.java
edu.grinnell.sandb.img.BodyImageGetter.java
edu.grinnell.sandb.img.ImageStorageHelper.java
edu.grinnell.sandb.img.ImageTable.java
edu.grinnell.sandb.img.Image.java
edu.grinnell.sandb.img.UniversalLoaderUtility.java
edu.grinnell.sandb.xmlpull.CommentParseTask.java
edu.grinnell.sandb.xmlpull.XmlCheckAgeTask.java
edu.grinnell.sandb.xmlpull.XmlFetchTask.java
edu.grinnell.sandb.xmlpull.XmlParseTask.java
edu.grinnell.sandb.xmlpull.XmlPullReceiver.java
edu.grinnell.sandb.xmlpull.XmlPullService.java