Android开发中从SQLite数据库获取新插入数据自增长的ID值
使用last_insert_rowid()函数
转自:http://blog.csdn.net/ssun125/article/details/7628071
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+"");
