0
I was wondering if I have how to insert a record in the database and already returns the id of this record in android sqlite
use this method to insert
public boolean insertH(HistoricoObjeto historico) {
/* Mapa com a coluna e os valores de cada coluna. */
ContentValues values = new ContentValues();
values.put("datahora", historico.getDatahora());
values.put("mensagem", historico.getMensagem());
/* Executa um insert no banco de dados usando o mapa de valores. */
/* Retorna -1 caso ocorra algum erro no INSERT. */
long retorno = this.banco.insert("historico", null, values);
if(retorno != -1)
return true;
else
return false;
}
http://www.sqlite.org/lang_corefunc.html#last_insert_rowid
– Pedro Oliveira
Have you ever thought of doing a query by returning the last record inserted in the default order.
– Marconi