Android examples for Database:Auto Incremental ID
get Next New Id to auto incremental id
//package com.java2s; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; public class Main { public static long getNewId(SQLiteDatabase db, String table) { long id = 1; Cursor cursor = db.rawQuery("select max(id) from " + table + " where id < 10000", null); if (cursor.moveToFirst()) id = cursor.getLong(0) + 1;//from w ww . j a v a 2 s .c o m cursor.close(); return id; } }