If you think the Android project Gazetti_Newspaper_Reader 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 in.sahildave.gazetti.bookmarks.sqlite;
//www.java2s.comimport android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;
/**
* Created by sahil on 13/10/14.
*/publicclass SQLiteHelper extends SQLiteOpenHelper{
privatestatic SQLiteHelper sInstance;
public SQLiteDatabase database;
privatestaticfinal String DATABASE_NAME = "gazetti_ril.db";
privatestaticfinalint DATABASE_VERSION = 1;
publicstaticfinal String COLUMN_ID = "_id";
publicstaticfinal String COLUMN_NEWS_HEADLINE = "news_title";
publicstaticfinal String COLUMN_NEWS_BODY = "news_body";
publicstaticfinal String COLUMN_NEWS_ARTICLE_URL = "link";
publicstaticfinal String COLUMN_NEWS_PUB_DATE = "pub_date";
publicstaticfinal String COLUMN_NEWS_IMAGE_URL = "news_image_url";
publicstaticfinal String COLUMN_NEWSPAPER_NAME = "newspaper_name_column";
publicstaticfinal String COLUMN_CATEGORY_NAME = "category_name_column";
publicstaticfinal String TABLE_READ_IT_LATER = "read_it_later";
privatestaticfinal String CREATE_TABLE_RIL =
"CREATE TABLE " + TABLE_READ_IT_LATER + "("
+ COLUMN_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, "
+ COLUMN_NEWSPAPER_NAME + " TEXT NOT NULL, "
+ COLUMN_CATEGORY_NAME + " TEXT NOT NULL, "
+ COLUMN_NEWS_HEADLINE + " TEXT NOT NULL, "
+ COLUMN_NEWS_BODY + " TEXT NOT NULL, "
+ COLUMN_NEWS_ARTICLE_URL + " TEXT NOT NULL, "
+ COLUMN_NEWS_PUB_DATE + " TEXT NOT NULL, "
+ COLUMN_NEWS_IMAGE_URL + " TEXT NOT NULL "
+ ");";
publicstatic SQLiteHelper getInstance(Context context) {
if (sInstance == null) {
sInstance = new SQLiteHelper(context);
}
return sInstance;
}
public SQLiteHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
@Override
publicvoid onCreate(SQLiteDatabase db) {
db.execSQL(CREATE_TABLE_RIL);
}
@Override
publicvoid onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
Log.w(SQLiteHelper.class.getName(),
"Upgrading database from version " + oldVersion + " to "
+ newVersion + ", which will destroy all old data");
db.execSQL("DROP TABLE IF EXISTS " + TABLE_READ_IT_LATER);
onCreate(db);
}
}