VOOZH about

URL: https://www.geeksforgeeks.org/android/how-to-retrieve-blogs-on-user-profile-in-social-media-android-app/

⇱ How to Retrieve Blogs on User Profile in Social Media Android App? - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

How to Retrieve Blogs on User Profile in Social Media Android App?

Last Updated : 23 May, 2024

This is the Part 16 of "Build a Social Media App on Android Studio" tutorial, and we are going to cover the following functionalities in this article:

  • We are going to Retrieve Blogs Written by users on their profile fragment.
  • As previously we have already added Data of users in Profile Fragment like email, name, and profile pic.
  • Here we are also going to retrieve Blogs Written By the current user on their profile.
  • Let's See the implementation of showing the blogs written by the current user.

Step By Step Implementation

Step 1: Working with the fragment_profile.xml file

Here we are adding a RecyclerView to view the blogs posted by the current user.

Step 2: Working with the ProfileFragment.java file

Here we are going to retrieve value from the Posts node in such a way that uid of the current user is equal to uid of the user having a post

DatabaseReference databaseReference=FirebaseDatabase.getInstance().getReference("Posts");
Query query=databaseReference.orderByChild("uid").equalTo(uid);

Below is the code for the ProfileFragment.java file.

Output:

Note: Please Add drawable items before running the Application

Below is the final file structure after performing these operations:

👁 Image
👁 Image

GitHub link for this project: https://github.com/Anni1123/SocialMediaPlatform

Comment
Article Tags:
Article Tags:

Explore