insert record via ContentValues to SQLiteDatabase - Android Database

Android examples for Database:ContentValues

Description

insert record via ContentValues to SQLiteDatabase

Demo Code


//package com.java2s;
import android.content.ContentValues;

import android.database.sqlite.SQLiteDatabase;

public class Main {
    public static final String STUDENT_TABLE = "STUDENT";
    public static final String STUDENT_NUMBER = "NUMBER";
    public static final String STUDENT_NAME = "STUNAME";

    public static void insertStudent(final SQLiteDatabase database,
            final String id, final String name) {
        final ContentValues courseValues;

        courseValues = new ContentValues();
        courseValues.put(STUDENT_NUMBER, id);
        courseValues.put(STUDENT_NAME, name);
        database.insert(STUDENT_TABLE, null, courseValues);
    }//  www.  ja v a  2 s .  co  m
}

Related Tutorials