0

Image.png > I have a Client app and Driver app under 1 Firebase Project.

This link is only said yes it can be done, but how can it be done?? not stated

  • Two different google-services.json
  • One Firebase Database for both
  • When from Customer app order is made, it is saving to Database as a child("Orders"), and as a test, I can retrieve those Orders in Customer app.

But how to retrieve those Orders in Driver app??

This is a piece of code, in Driver app which tries to retrieve data from Customer app.

final DatabaseReference rootRef = FirebaseDatabase.getInstance().getReference("Orders");

    final ValueEventListener eventListener = new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            for (DataSnapshot ds : dataSnapshot.getChildren()) {
                String name = ds.child("name").getValue(String.class);
                String surname = ds.child("surname").getValue(String.class);
                String beverages = ds.child("beverages").getValue(String.class);
                String deserts = ds.child("deserts").getValue(String.class);
                String time = ds.child("time").getValue(String.class);

                edtx_name.setText(name);
                edtx_surname.setText(surname);
                edtx_beverages.setText(beverages);
                edtx_deserts.setText(deserts);
                edtx_time.setText(time);

                Log.d("Test", "" + edtx_name + "/" + edtx_surname + "/" + edtx_beverages + "/" + edtx_deserts + "/" + edtx_time);
            }
        }
        @Override
        public void onCancelled(DatabaseError databaseError) {}
    };
    rootRef.addListenerForSingleValueEvent(eventListener);

But this doesnt retrieve. what am i making wrong?

J_J_J
  • 1
  • 1
  • How should we know, you might consider adding information about your database? – creativecreatorormaybenot Oct 02 '17 at 19:29
  • Sorry? can you explain in a more detail what you are saying? – J_J_J Oct 02 '17 at 19:30
  • How would you expect anyone to know how to solve your problem from your data given? We do not know anything about your database or Firebase project. – creativecreatorormaybenot Oct 02 '17 at 19:37
  • 1 DB, 1 child object called "Orders" . inside "Orders" I have set .push() to generate random unique keys. I have set value to those edittexts such as name, surname, beverages........ If client fills edittexts, the data is saved in the firebase project. I can see that. But, how should i retrieve that data from my driver app. anything else you should know? – J_J_J Oct 02 '17 at 19:47
  • I have uploaded an image bro. – J_J_J Oct 02 '17 at 19:48

0 Answers0