I need to add initial values to SQLite database, once application is started first time. How should I do it?
You should use SQLiteOpenHelper for this
private static class OpenHelper extends SQLiteOpenHelper {
private static final String DATABASE_NAME = "rss.sqlite";
private static final int DATABASE_VERSION = 1;
OpenHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL("CREATE TABLE RSS (TITLE TEXT, LINK TEXT, DESCR TEXT, PUBDATE DATE, GUID TEXT, READ TEXT, TYPE TEXT)");
db.execSQL("CREATE TABLE PAGE (LINK TEXT, CONTENT TEXT)");
}
@Override
public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {
}
}
And use it in code
OpenHelper openHelper = new OpenHelper(this.context);
this.db = openHelper.getWritableDatabase();