My app keeps crashing when it sets the persistence-enable. If the parent field is found in Firebase it crashes, if not, it loads the layout properly. Then on storing data on firebase it crashes again as now the parent is found in the database.
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_chat_line);
final DatabaseReference reference1, reference2;
if(!FirebaseApp.getApps(this).isEmpty()) {
FirebaseDatabase.getInstance().setPersistenceEnabled(true);
}
layout = (LinearLayout)findViewById(R.id.layout1);
sendButton = (ImageView)findViewById(R.id.sendButton);
messageArea = (EditText)findViewById(R.id.messageArea);
scrollView = (ScrollView)findViewById(R.id.scrollView);
reference1 = FirebaseDatabase.getInstance().getReference("message/" + "username" + "_" + "admin");
reference2 = FirebaseDatabase.getInstance().getReference("message/" + "admin" + "_" + "username");