create table with integer PRIMARY KEY auto increment - Android Database

Android examples for Database:Primary Key

Description

create table with integer PRIMARY KEY auto increment

Demo Code


//package com.java2s;

import android.database.sqlite.SQLiteDatabase;

import android.util.Log;

public class Main {
    public static SQLiteDatabase db;
    public static String workname = "worklist";

    public static void createWorktable() {
        try {/*from w ww .jav a  2s  .  c om*/
            db.execSQL("create table if not exists " + workname + "("
                    + " _id integer PRIMARY KEY autoincrement, "
                    + " cownumber text," + " year text," + " month text, "
                    + " day text, " + " hour text, " + " min text, "
                    + " simplememo text, " + " resetNum text);");
        } catch (Exception ext) {
            Log.d("Create table fail", "table make fail");
        }
    }
}

Related Tutorials