简体   繁体   中英

how to retrive users data android firebase

please guys how to retrive data from firebase when the user save something then he wants to retrive it this is the saving code

        fireapp=new Firebase("https://training-a3c4e.firebaseio.com/User");
        btn1=findViewById(R.id.button);
        btn2=findViewById(R.id.button2);
        ed1=findViewById(R.id.editText);
        ed2=findViewById(R.id.editText3);

        btn1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
               String data1=ed1.getText().toString();
               String data2=ed2.getText().toString();

                Firebase getRoot=fireapp.child(data2);
                // Firebase.goOffline();
                getRoot.setValue(data1);
            }
        }

You can do the following

fireapp=new Firebase("https://training-a3c4e.firebaseio.com/User").child(data2);
fireapp.addListenerForSingleValueEvent(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            // your data will be here in dataSnapshot

        }
    });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM