android sqlite获取插入的最后一条数据id
//方法一 Cursor c = database.rawQuery("SELECT lastinsertrowid()", null); c.moveToFirst(); int id = c.getInt(0); //方法二 Cursor c = database.rawQuery("SELECT max(_id) FROM *Table limit 1", null); int id = c.getInt(0);
//方法一 Cursor c = database.rawQuery("SELECT lastinsertrowid()", null); c.moveToFirst(); int id = c.getInt(0); //方法二 Cursor c = database.rawQuery("SELECT max(_id) FROM *Table limit 1", null); int id = c.getInt(0);