我正在进行一个andoird项目,我需要将我的应用程序连接到2个firebase数据库。问题是,当我在应用程序中午餐时,它会崩溃。我在这里找到了一些建议:Firebase Authentication Limits 但它不起作用。我该怎么办? thx提前
//FIREBASE_URL is used to store data in a firebase database
private static final String FIREBASE_URL ="https://**********.firebaseio.com/";
//FIREBASE_STRING is used to read data from another firebase database
private static final String FIREBASE_STRING ="https://++++++++++++.firebaseio.com/";
private Firebase firebaseRef;
private Firebase fbRef;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Firebase.setAndroidContext(this);
firebaseRef = new Firebase(FIREBASE_URL);
fbRef = new Firebase(FIREBASE_STRING);
}
//The app crashes when this methode
//This methode is used to read data from the second direbase database
public void itineraryListener() {
fbRef.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot snapshot) {
Toast.makeText(getApplicationContext(), "There are " + snapshot.getChildrenCount() + " locations", Toast.LENGTH_SHORT).show();
for (DataSnapshot postSnapshot : snapshot.getChildren()) {
Itinerary post = postSnapshot.getValue(Itinerary.class);
}
@Override
public void onCancelled(FirebaseError firebaseError) {
Toast.makeText(getApplicationContext(), "An error occured! " + firebaseError.getMessage(), Toast.LENGTH_SHORT).show();
}
});
}
}
写作方法运作良好,但阅读方法不适用