使用last_insert_rowid()函数,例如:
1 SQLiteDatabase db = helper.getWritableDatabase();
2 db.execSQL("insert into person(name,phone,amount) values(?,?,?) ",
3 new Object[]{person.getName(),person.getPhone(),person.getAmount()});
4 Cursor cursor = db.rawQuery("select last_insert_rowid() from person",null);
5 int strid;
6 if(cursor.moveToFirst())
7 strid = cursor.getInt(0);
8 Log.i("testAuto", strid+"");