将做工程过程中常用的内容珍藏起来,下面内容段是关于Android开发中从SQLite数据库获取新插入数据自增长的ID值的内容,希望对各位朋友有用处。
SQLiteDatabase db = helper.getWritableDatabase();
db.execSQL("insert into person(name,phone,amount) values(?,?,?) ",
new Object[]{person.getName(),person.getPhone(),person.getAmount()});
Cursor cursor = db.rawQuery("select last_insert_rowid() from person",null);
int strid;
if(cursor.moveToFirst())
strid = cursor.getInt(0);
Log.i("testAuto", strid+"");