retrieving firebase data into a textview with no button in android studio

i have a few textviews which i want to change from firebase database on a daily basis for that i am retrieving data from firebase realtime database to a textview i have tried many times but it just doesnt seem to work,please help me guys.

this is my java code.

       tv1 = findViewById ( R.id.tv1 );
       tv2 = findViewById ( R.id.tv2 );
       tv3 = findViewById ( R.id.tv3 );
       tv4 = findViewById ( R.id.tv4 );
       tv5 = findViewById ( R.id.tv5 );
       tv6 = findViewById ( R.id.tv6 );
       tv7 = findViewById ( R.id.tv7 );
       tv8 = findViewById ( R.id.tv8 );
       tv9 = findViewById ( R.id.tv9 );
       tv10 = findViewById ( R.id.tv10 );

       mDatabase = FirebaseDatabase.getInstance ();
       ref= mDatabase.getReference ().child ("textview1");

       ref.addValueEventListener ( new ValueEventListener ( ) {
           @Override
           public void onDataChange(@NonNull DataSnapshot snapshot) {


               String tv1s = snapshot.child ( "textview1" ).getValue ( String.class );
               String tv2s = snapshot.child ( "textview2" ).getValue ( String.class );
               String tv3s = snapshot.child ( "textview3" ).getValue ( String.class );
               String tv4s = snapshot.child ( "textview4" ).getValue ( String.class );
             

               tv1.setText ( tv1s );
               tv2.setText ( tv2s );
               tv3.setText ( tv3s );
               tv4.setText ( tv4s );
             



           }

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

           }
       } );

this is my firebase database

 {
  "textview1" : 2200,
  "textview10" : 244,
  "textview2" : 13,
  "textview3" : 12,
  "textview4" : 13,
 
}

when i open app all the text just vanishes and i dont any reason for that. i have lots of textview which i want to update from day to day basis if you guys have any suggestions i am open to hear it.

basic idea is to update values
suppose i have 10 textview in gridlayout so they will be 10-1, 11-2, 12-3 and so on and here both or every numbers are textview i want to change this numbers everyday according to need so thas why i am asking for help.

i am adding more words so that my question will be accepted and i think you all got the idea of what i am trying to say.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.