I do work around an application that displays data from a database on a firebase but there is a problem that if the user does not have a connection in the internet the blank page appears containing nothing Use this code to view data.

    ref.child("Sat").addValueEventListener(new ValueEventListener() {

        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {

            satelliteList.clear();


            for (DataSnapshot snapshot : dataSnapshot.getChildren()) {
                Satellite satellite = snapshot.getValue(Satellite.class);
                satelliteList.add(satellite);
                adapter.notifyDataSetChanged();
            }
            Collections.reverse(satelliteList);
        }

        @Override
        public void onCancelled(DatabaseError databaseError) {


        }
    });

0 Answers