Sunday , January 16 2022

Firebase Storage Example – Uploading and Retrieving Files – Android Coding by DMTechnolab

The package The trap.Simplified coding.Fire engine;

Import Android.App.Progressressialog;

Import Android.Support.v7.App.AppCompatActivity;

Import Android.The.Bundle;

Import Android.Support.v7.Widget.Linearlutmanagar;

Import Android.Support.v7.Widget.RecyclerView;

Import Android.Useful.Log;

Import Android.Widget.Toast;

Import With.Google.Fire.The database.DataSnapshot;

Import With.Google.Fire.The database.Database error;

Import With.Google.Fire.The database.DatabaseReference;

Import With.Google.Fire.The database.FirebaseDatabase;

Import With.Google.Fire.The database.ValueEventListener;

Import Java.Useful.array list;

Import Java.Useful.The list;

public class ShowImagesActivity Is spread AppCompatActivity {{

// recyclerview object

Private RecyclerView recyclerView;

// adapter object

Private RecyclerView.Adapter Adopter;

// database reference

Private DatabaseReference mDatabase;

// progress dialog

Private Progressressialog PragatiDialogue;

// List to keep all uploaded images

Private The list Uploads;

@Override

Protected Zero Go ahead()Bundle saveInstanceState) {{

Super.Go ahead()saveInstanceState);

setContentView()R.Layout.activity_show_images);

recyclerView = ()RecyclerView) findViewById()R.Id.recyclerView);

recyclerView.setHasFixedSize()True);

recyclerView.setLayoutManager()New Linearlutmanagar()this));

PragatiDialogue = New Progressressialog()this);

Uploads = New array list());

// Displaying progress dialog while fetching pictures

PragatiDialogue.Setmessage()“Please wait …”);

PragatiDialogue.Display());

mDatabase = FirebaseDatabase.get Instance()).refer to()continuously.DATABASE_PATH_UPLOADS);

// Add an event listener to fetch values

mDatabase.addValueEventListener()New ValueEventListener()) {{

@Override

public Zero onDataChange()DataSnapshot Snapshot) {{

// dismissing the progress dialog

PragatiDialogue.reject());

// iterate through all the values ​​in the database

For ()DataSnapshot PostSnapshot : Snapshot.getChildren())) {{

Pour Pour = PostSnapshot.getValue()Pour.class);

Uploads.Add up()Pour);

}

// Creating adapters

Adopter = New My adapter()getApplicationContext()), Uploads);

// Adding adapters to recyclerview

recyclerView.setAdapter()Adopter);

}

@Override

public Zero Turned on()Database error Database error) {{

PragatiDialogue.reject());

}

});

}

}


Source link

About dmtechnolab

Check Also

Simplified Coding

Android Espresso Tutorial – Testing Fragment in Isolation – Android Coding by DMTechnolab

Welcome to another tutorial in the Android test series. And this post is called Android …

Leave a Reply

Your email address will not be published. Required fields are marked *