lundi 15 février 2016

Inserting Rows of Data into an Sqlite Database

I am just wondering how to programmatically insert values into a data base. I have created a Database and just want to create a large array of strings inside that database. Does anyone know how this could easily be accomplished.

Here is what I have so Far

public class GroupDatabase extends SQLiteOpenHelper {

public static final String DATABASE_NAME = "GroupTopics.db";
public static final String TABLE_NAME = "Topics_Table";
public static final String COL_1 = "Id";
public static final String COL_2 = "Topics";

public GroupDatabase(Context context) {
    super(context, DATABASE_NAME, null, 1);
    SQLiteDatabase db = this.getWritableDatabase();
}

@Override
public void onCreate(SQLiteDatabase db) {
    db.execSQL("create table" + TABLE_NAME + "(ID INTEGER PRIMARY KEY AUTOINCREMENT, TOPICS)");

}

@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

}

} Where do I insert the data for the rows of the database? Any Help is appreciated:)

Aucun commentaire:

Enregistrer un commentaire