val values = ContentValues()values.put("name", "Test 01")val id = db.insert("table_name", SQLiteDatabase.CONFLICT_REPLACE, values)val cursor = db.query("SELECT * FROM pin WHERE rowid = ?", arrayOf(id))// val cursor = db.query("SELECT * FROM pin WHERE id = ?", arrayOf(id))if (cursor != null && cursor.moveToFirst()) { // using android-ktx val name = cursor.getString("name")}
NOTE: SQLiteDatabase.insert return the row ID of the newly inserted row, or -1 if an error occurred
.
NOTE: It should work if your id is autogenerated, though I have not tested it.