如何在其他地方重复使用从firebaseDatabase获得的数据?

时间:2019-05-30 23:21:52

标签: android firebase-realtime-database

String currentuser = FirebaseAuth.getInstance().getCurrentUser().getUid();

@Override
    public void onLocationChanged(Location location) {


        final Ticket ticket = new Ticket();
        nameBusssLine = FirebaseDatabase.getInstance().getReference("Users");
        nameBusssLine.child(currentuser).addValueEventListener(new ValueEventListener() {
            @Override
            public void onDataChange(@NonNull DataSnapshot dataSnapshot) {


                String xx = dataSnapshot.child("bus_line").getValue().toString();
                ticket.setBusLine(xx);


            }

            @Override
            public void onCancelled(@NonNull DatabaseError databaseError) {

            }
        });

Toast.makeText(DriverHome.this, xx, Toast.LENGTH_SHORT).show();
        Toast.makeText(DriverHome.this, ticket.getBusLine(), Toast.LENGTH_SHORT).show();



    }

0 个答案:

没有答案