I have a Firebase Database that I use to fill a ListView with FirebaseUI. Everything works fine (offline and online) until the app is killed and restarted without internet. When this happens, the database is empty and once the internet is back everything it synchronizes perfectl.
I use:
Firebase.getDefaultConfig().setPersistenceEnabled(true);
but it doesn't change anything. What should I do to in order to have the offline Db even after killing the app?
database = FirebaseDatabase.getInstance(FirebaseApp.getInstance());
ref = database.getReference(FirebaseAuth.getInstance(FirebaseApp.getInstance()).getCurrentUser().getUid())
.child("Tasks");
Log.d(TAG,"User ID: " +FirebaseAuth.getInstance(FirebaseApp.getInstance()).getCurrentUser().getUid());
Log.d(TAG,"DB: " +database);
Log.d(TAG,"Ref: " +ref);
mAdapter = new FirebaseListAdapter<Task>(getActivity(), Task.class, R.layout.task_view,ref) {
@Override
protected void populateView(View v, Task model, int position) {
TextView task = (TextView) v.findViewById(R.id.task_text);
CheckBox checkBox = (CheckBox) v.findViewById(R.id.checkbox);
task.setText(model.getText());
checkBox.setChecked(model.getDone()==1);
}
};
listView.setAdapter(mAdapter);