Tuffy G
Tuffy G

Reputation: 1521

sqlite tutorial create and view

I am looking for an example or tutorial for sqlite. What I need to do is put info into the database from an input then on another screen display what has been inputted previously.

I know it's pretty basic stuff but I don't know what to do. (I'm not asking for someone to do it for me just a tutorial that I could learn from

any help would be appreciated

Upvotes: 0

Views: 278

Answers (1)

Barak
Barak

Reputation: 16393

This might be useful.

EDIT

An example from one of my projects:

in my datacollection class:

private EditText titleText;
private EditText descText;

private String title;
private String desc;

titleText = (EditText) v.findViewById(R.id.title);
descText = (EditText) v.findViewById(R.id.desc);

commit.setOnClickListener(new OnClickListener() {public void onClick(View v) {
    title = titleText.getText().toString();
    desc = descText.getText().toString();
    mDbHelper.createEventType(title, desc);
}

in my dbhelper class:

public long createEventType(String eventType, String eventTypeDesc) {
    ContentValues initialValues = new ContentValues();
    initialValues.put(EVENTTYPE_NAME, eventType);
    initialValues.put(EVENTTYPE_DESC, eventTypeDesc);
    return mDb.insertWithOnConflict(EVENTTYPE_TABLE, null, initialValues,
            SQLiteDatabase.CONFLICT_IGNORE);
}

Upvotes: 1

Related Questions