0
I saved in my database using sugar every time I get a new notification, it works correctly, then in a Ragment I populate a recycleview with all database notifications, it also works correctly, but now when I try to delete from the database by id I can’t, my database returns null for some ids ( see the debug image), I’ve tried to understand but I can’t figure out why.
Addition code in the bank:
public void onMessageReceived(RemoteMessage remoteMessage) {
SugarContext.init( this );
Log.d("igr", "Mensagem Recebida");
if (remoteMessage.getData().size() > 0) {
Log.d("igr", "Message data payload: " + remoteMessage.getData());
String titulo = remoteMessage.getData().get("title");
String mensagem = remoteMessage.getData().get("text");
try{
Notificacao notificacao= new Notificacao(titulo,mensagem);
SugarRecord.save(notificacao);
SugarContext.terminate();
}catch (Exception e){
Log.d("igr", "Erro ao salvar notificacao no DB: " + e);
SugarContext.terminate();
}
My model:
package br.com.igoroliv.youtubecanal.DataBase;
import com.orm.dsl.Table;
/**
* Created by igord on 03/07/2017.
*/
@Table
public class Notificacao {
private Long id;
private String titulo;
private String texto;
public Notificacao(){
}
public Notificacao(String titulo, String texto) {
this.titulo = titulo;
this.texto = texto;
}
/* gets e sets */
public Long getId() {
return id;
}
public String getTitulo() {
return titulo;
}
public String getTexto() {
return texto;
}
}
Right the way I’m using, I’ve used without using @table and was giving the same error, the problem is that it depends a lot on the ID, some it deletes, others not .. That’s what I don’t understand
– Igor Oliveira
Honestly, it tries to implement the base using the native classes: Sqliteopenhelper and Sqlitedatabase. In my opinion, there is much more control doing so.
– Márcio Oliveira
I’ll try this, I wanted to use the sugar because the bank is extremely simple
– Igor Oliveira
The problem of these "simple" solutions is the complexity to solve the problems, rs
– Márcio Oliveira
refiz in Sqlite but still giving error :/ https://answall.com/questions/218926/porque-meu-delete-do-sqlite-diz-que-deletou-mas-n%C3%A3o-deleted
– Igor Oliveira