I'm not able to display database data for TextView.
BD
public MessageEB buscarConfiguracoes() {
String[] colunas = new String[]{"data"};
Cursor cursor = bd.query("dados", colunas, null, null, null, null, null);
MessageEB messageEB = new MessageEB();
if (cursor.moveToNext()) {
messageEB.setData(cursor.getString(0));
}
cursor.close();
return messageEB;
}
Fragment Submit
@Override
public void onClick(View v) {
Log.i("LOG", "FragmentEnviar.this.onClick()");
MessageEB m = new MessageEB();
m.setClassTester(FragmentExibir.class+"");
m.setData(editar.getText().toString());
EventBus.getDefault().post(m);
dados.setData(editar.getText().toString());
BD bd = new BD(getActivity());
bd.atualizar(dados);
Toast.makeText(getActivity(), "Data alterada com sucesso! " + dados.getData(), Toast.LENGTH_SHORT).show();
}
Fragment View
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
view = inflater.inflate(R.layout.fragment_exibir, container, false);
EventBus.getDefault().register(FragmentExibir.this);
txt = (TextView) view.findViewById(R.id.campoData2);
BD bd = new BD(getActivity());
txt.setText(bd.buscarConfiguracoes().getData());
return view;
}
Data is the name of the database table. When I call the database data, it is not displayed.