I'm learning to use sqlite.net
in Xamarin
, but at the time of editing an item is not working, I debugged the code and gave breakpoint
to EditItens()
and saw values passed to conexao.Query<Itens>
are correct, but the ones received in the variable Teste
below remain the same as previously, I'm missing something when editing the values in sqlite? There may also be something wrong with GetItens()
, but I find it kind of difficult because it works normally when used to grab values and show in ListView
of MainActivity
. Below the above methods
string pasta = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
public List<Itens> GetItens()
{
try
{
var conexao = new SQLiteConnection(System.IO.Path.Combine(pasta, "Itens.db3"));
return conexao.Table<Itens>().ToList();
}
catch (Exception)
{
return null;
}
}
public bool EditItens(Itens itens)
{
try
{
var conexao = new SQLiteConnection(System.IO.Path.Combine(pasta, "Itens.db3"));
conexao.Query<Itens>("UPDATE Itens set Nome=?,Preco=? Where Id=?", itens.Nome, itens.Preco, itens.Id);
Teste = GetItens();
return true;
}
catch (Exception)
{
return false;
}
}
If you can tell me where I can find pasta, "Itens.db3"
by Windows File Explorer, it will also help because I can verify that the item is not actually being edited.