I can not update the data that is in the database.
In the database class are the two functions refresh and searchConfigurations.
public void atualizar(MessageEB dados){
ContentValues valores = new ContentValues();
valores.put("data", dados.getData());
bd.update("dados", valores, "_id = ?", new String[]{"" + dados.getId()});
Log.i("a", dados.getData());
bd.close();
}
public MessageEB buscarConfiguracoes() {
MessageEB messageEB = new MessageEB();
String sqlSelectTodosLivros = "SELECT * FROM dados";
Cursor c = bd.rawQuery(sqlSelectTodosLivros, null);
if(c.moveToNext()) {
messageEB.setId(c.getLong(0));
messageEB.setData(c.getString(1));
Log.i("LOG", "funcao buscar");
}
Log.i("LOG", "fora do if "+(c.getString(1)));
bd.close();
return messageEB;
}
In the fragment where EditText has this code inside one:
public void onClick(View v) {
MessageEB dados = new MessageEB();
dados.setData(editar.getText().toString());
BD bd = new BD(getActivity());
bd.atualizar(dados);
}
In the fragment that will display the data:
txt = (TextView) view.findViewById(R.id.campoData2);
BD db = new BD(getActivity());
String s = db.buscarConfiguracoes().getData();
txt.setText(s);
When the data passed through the function refresh the data is changed, I saw this with a Log, but when it passes through the getConfigurations () the received data is the same as before the change.