how to read firestore sub-collection and pass it to FirestoreRecyclerOptionsUsing RecyclcerView on Fragment to display data from firestore, Do i need an adapter to each fragment?How can I add a custom marker to a map from data I input into FireStoreHow to fix images and data not retrieving from Firebase storage and realtime database respectively?Is Java “pass-by-reference” or “pass-by-value”?How do I efficiently iterate over each entry in a Java Map?How do save an Android Activity state using save instance state?How do I read / convert an InputStream into a String in Java?How do I generate random integers within a specific range in Java?Why is the Android emulator so slow? How can we speed up the Android emulator?How do I pass data between Activities in Android application?How do I convert a String to an int in Java?How do I fix android.os.NetworkOnMainThreadException?Multiple Adapters or One Adapter for different lists and objects - Code Performance

Do we have C++20 ranges library in GCC 9?

Are there any sonatas with only two sections?

Why can't I share a one use code with anyone else?

Why does lemon juice reduce the "fish" odor of sea food — specifically fish?

Is this possible when it comes to the relations of P, NP, NP-Hard and NP-Complete?

"The van's really booking"

How to cope with regret and shame about not fully utilizing opportunities during PhD?

Re-testing of regression test bug fixes or re-run regression tests?

Why are solar panels kept tilted?

Is there an academic word that means "to split hairs over"?

The meaning of the Middle English word “king”

Was the dragon prowess intentionally downplayed in S08E04?

Formal Definition of Dot Product

Do not cross the line!

Where to find every-day healthy food near Heathrow Airport?

Polynomial division: Is this trick obvious?

Under what charges was this character executed in Game of Thrones, The Bells?

Can multiple outlets be directly attached to a single breaker?

Were any of the books mentioned in this scene from the movie Hackers real?

How to disable Two-factor authentication for Apple ID?

Extract the characters before last colon

Why is it harder to turn a motor/generator with shorted terminals?

Will casting a card from the graveyard with Flashback add a quest counter on Pyromancer Ascension?

Is 95% of what you read in the financial press “either wrong or irrelevant?”



how to read firestore sub-collection and pass it to FirestoreRecyclerOptions


Using RecyclcerView on Fragment to display data from firestore, Do i need an adapter to each fragment?How can I add a custom marker to a map from data I input into FireStoreHow to fix images and data not retrieving from Firebase storage and realtime database respectively?Is Java “pass-by-reference” or “pass-by-value”?How do I efficiently iterate over each entry in a Java Map?How do save an Android Activity state using save instance state?How do I read / convert an InputStream into a String in Java?How do I generate random integers within a specific range in Java?Why is the Android emulator so slow? How can we speed up the Android emulator?How do I pass data between Activities in Android application?How do I convert a String to an int in Java?How do I fix android.os.NetworkOnMainThreadException?Multiple Adapters or One Adapter for different lists and objects - Code Performance






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















enter image description hereI have firestore database with root products and every products has collection 'comments' so i stored in it all users comments about this product , but when query on this comments sub-collection i get null values or zero snapshots from firestore



 private void getCommentObject()



query = FirebaseFirestore.getInstance()
.collection("products").document(docID).collection("comments");

FirestoreRecyclerOptions<CommentModel> options = new FirestoreRecyclerOptions.Builder<CommentModel>()
.setQuery(query, CommentModel.class)
.build();


adapter = new FirestoreRecyclerAdapter<CommentModel, commentHolder>(options)
@NonNull
@Override
public commentHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType)
View view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.comment_item_layout, parent, false);

return new commentHolder(view);


@Override
protected void onBindViewHolder(@NonNull commentHolder commentHolder, int position, @NonNull CommentModel commentModel)


commentHolder.full_comment.setText(String.valueOf(commentModel.getComment()));
commentHolder.comment_date.setText(String.valueOf(commentModel.getCommentDate()));
commentHolder.comment_user.setText(String.valueOf(commentModel.getCommentUser()));


Glide.with(getApplicationContext())
.load(commentModel.getProfilePic())
.into(commentHolder.userProfileImg);

;

;



rv.setAdapter(adapter);
adapter.notifyDataSetChanged();




and here is my commentModel calss



@IgnoreExtraProperties


public class CommentModel implements Serializable



public CommentModel() 



String comment , commentDate , profilePic , commentUser ;

public CommentModel(String comment)
this.comment = comment;


public String getComment()
return this.comment;


public void setComment(String Comment)
this.comment = comment;


public String getCommentDate()
return this.commentDate;


public void setCommentDate(String commentDate)
commentDate = commentDate;


public String getProfilePic()
return profilePic;


public void setProfilePic(String profilePic)
this.profilePic = profilePic;


public String getCommentUser()
return commentUser;


public void setCommentUser(String commentUser)
commentUser = commentUser;





enter image description here










share|improve this question
























  • Please add the strucutre of your comments collection and confirm that you have started listening for changes.

    – Alex Mamo
    Dec 27 '18 at 6:36











  • i have added comments screen shot and comment model class , and yes i was use code for start listening @Override protected void onStart() super.onStart(); adapter.startListening(); but get null values in recyclerview

    – Hashoma El-Nemr
    Dec 27 '18 at 9:35


















0















enter image description hereI have firestore database with root products and every products has collection 'comments' so i stored in it all users comments about this product , but when query on this comments sub-collection i get null values or zero snapshots from firestore



 private void getCommentObject()



query = FirebaseFirestore.getInstance()
.collection("products").document(docID).collection("comments");

FirestoreRecyclerOptions<CommentModel> options = new FirestoreRecyclerOptions.Builder<CommentModel>()
.setQuery(query, CommentModel.class)
.build();


adapter = new FirestoreRecyclerAdapter<CommentModel, commentHolder>(options)
@NonNull
@Override
public commentHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType)
View view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.comment_item_layout, parent, false);

return new commentHolder(view);


@Override
protected void onBindViewHolder(@NonNull commentHolder commentHolder, int position, @NonNull CommentModel commentModel)


commentHolder.full_comment.setText(String.valueOf(commentModel.getComment()));
commentHolder.comment_date.setText(String.valueOf(commentModel.getCommentDate()));
commentHolder.comment_user.setText(String.valueOf(commentModel.getCommentUser()));


Glide.with(getApplicationContext())
.load(commentModel.getProfilePic())
.into(commentHolder.userProfileImg);

;

;



rv.setAdapter(adapter);
adapter.notifyDataSetChanged();




and here is my commentModel calss



@IgnoreExtraProperties


public class CommentModel implements Serializable



public CommentModel() 



String comment , commentDate , profilePic , commentUser ;

public CommentModel(String comment)
this.comment = comment;


public String getComment()
return this.comment;


public void setComment(String Comment)
this.comment = comment;


public String getCommentDate()
return this.commentDate;


public void setCommentDate(String commentDate)
commentDate = commentDate;


public String getProfilePic()
return profilePic;


public void setProfilePic(String profilePic)
this.profilePic = profilePic;


public String getCommentUser()
return commentUser;


public void setCommentUser(String commentUser)
commentUser = commentUser;





enter image description here










share|improve this question
























  • Please add the strucutre of your comments collection and confirm that you have started listening for changes.

    – Alex Mamo
    Dec 27 '18 at 6:36











  • i have added comments screen shot and comment model class , and yes i was use code for start listening @Override protected void onStart() super.onStart(); adapter.startListening(); but get null values in recyclerview

    – Hashoma El-Nemr
    Dec 27 '18 at 9:35














0












0








0








enter image description hereI have firestore database with root products and every products has collection 'comments' so i stored in it all users comments about this product , but when query on this comments sub-collection i get null values or zero snapshots from firestore



 private void getCommentObject()



query = FirebaseFirestore.getInstance()
.collection("products").document(docID).collection("comments");

FirestoreRecyclerOptions<CommentModel> options = new FirestoreRecyclerOptions.Builder<CommentModel>()
.setQuery(query, CommentModel.class)
.build();


adapter = new FirestoreRecyclerAdapter<CommentModel, commentHolder>(options)
@NonNull
@Override
public commentHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType)
View view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.comment_item_layout, parent, false);

return new commentHolder(view);


@Override
protected void onBindViewHolder(@NonNull commentHolder commentHolder, int position, @NonNull CommentModel commentModel)


commentHolder.full_comment.setText(String.valueOf(commentModel.getComment()));
commentHolder.comment_date.setText(String.valueOf(commentModel.getCommentDate()));
commentHolder.comment_user.setText(String.valueOf(commentModel.getCommentUser()));


Glide.with(getApplicationContext())
.load(commentModel.getProfilePic())
.into(commentHolder.userProfileImg);

;

;



rv.setAdapter(adapter);
adapter.notifyDataSetChanged();




and here is my commentModel calss



@IgnoreExtraProperties


public class CommentModel implements Serializable



public CommentModel() 



String comment , commentDate , profilePic , commentUser ;

public CommentModel(String comment)
this.comment = comment;


public String getComment()
return this.comment;


public void setComment(String Comment)
this.comment = comment;


public String getCommentDate()
return this.commentDate;


public void setCommentDate(String commentDate)
commentDate = commentDate;


public String getProfilePic()
return profilePic;


public void setProfilePic(String profilePic)
this.profilePic = profilePic;


public String getCommentUser()
return commentUser;


public void setCommentUser(String commentUser)
commentUser = commentUser;





enter image description here










share|improve this question
















enter image description hereI have firestore database with root products and every products has collection 'comments' so i stored in it all users comments about this product , but when query on this comments sub-collection i get null values or zero snapshots from firestore



 private void getCommentObject()



query = FirebaseFirestore.getInstance()
.collection("products").document(docID).collection("comments");

FirestoreRecyclerOptions<CommentModel> options = new FirestoreRecyclerOptions.Builder<CommentModel>()
.setQuery(query, CommentModel.class)
.build();


adapter = new FirestoreRecyclerAdapter<CommentModel, commentHolder>(options)
@NonNull
@Override
public commentHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType)
View view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.comment_item_layout, parent, false);

return new commentHolder(view);


@Override
protected void onBindViewHolder(@NonNull commentHolder commentHolder, int position, @NonNull CommentModel commentModel)


commentHolder.full_comment.setText(String.valueOf(commentModel.getComment()));
commentHolder.comment_date.setText(String.valueOf(commentModel.getCommentDate()));
commentHolder.comment_user.setText(String.valueOf(commentModel.getCommentUser()));


Glide.with(getApplicationContext())
.load(commentModel.getProfilePic())
.into(commentHolder.userProfileImg);

;

;



rv.setAdapter(adapter);
adapter.notifyDataSetChanged();




and here is my commentModel calss



@IgnoreExtraProperties


public class CommentModel implements Serializable



public CommentModel() 



String comment , commentDate , profilePic , commentUser ;

public CommentModel(String comment)
this.comment = comment;


public String getComment()
return this.comment;


public void setComment(String Comment)
this.comment = comment;


public String getCommentDate()
return this.commentDate;


public void setCommentDate(String commentDate)
commentDate = commentDate;


public String getProfilePic()
return profilePic;


public void setProfilePic(String profilePic)
this.profilePic = profilePic;


public String getCommentUser()
return commentUser;


public void setCommentUser(String commentUser)
commentUser = commentUser;





enter image description here







java android firebase google-cloud-firestore






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 27 '18 at 9:34







Hashoma El-Nemr

















asked Dec 25 '18 at 17:05









Hashoma El-NemrHashoma El-Nemr

258




258












  • Please add the strucutre of your comments collection and confirm that you have started listening for changes.

    – Alex Mamo
    Dec 27 '18 at 6:36











  • i have added comments screen shot and comment model class , and yes i was use code for start listening @Override protected void onStart() super.onStart(); adapter.startListening(); but get null values in recyclerview

    – Hashoma El-Nemr
    Dec 27 '18 at 9:35


















  • Please add the strucutre of your comments collection and confirm that you have started listening for changes.

    – Alex Mamo
    Dec 27 '18 at 6:36











  • i have added comments screen shot and comment model class , and yes i was use code for start listening @Override protected void onStart() super.onStart(); adapter.startListening(); but get null values in recyclerview

    – Hashoma El-Nemr
    Dec 27 '18 at 9:35

















Please add the strucutre of your comments collection and confirm that you have started listening for changes.

– Alex Mamo
Dec 27 '18 at 6:36





Please add the strucutre of your comments collection and confirm that you have started listening for changes.

– Alex Mamo
Dec 27 '18 at 6:36













i have added comments screen shot and comment model class , and yes i was use code for start listening @Override protected void onStart() super.onStart(); adapter.startListening(); but get null values in recyclerview

– Hashoma El-Nemr
Dec 27 '18 at 9:35






i have added comments screen shot and comment model class , and yes i was use code for start listening @Override protected void onStart() super.onStart(); adapter.startListening(); but get null values in recyclerview

– Hashoma El-Nemr
Dec 27 '18 at 9:35













1 Answer
1






active

oldest

votes


















1














The problem in your code lies in the fact that the name of the fields in your CommentModel class are different than the name of the properties in your database. You have in your CommentModel class a field named comment but in your database I see it as Comment and this is not correct. The names must match. When you are using a getter named getComment(), Firebase is looking in the database for a field named comment and not Comment. See the lowercase c letter vs. capital letter C?



There are two ways in which you can solve this problem. The first one would be to change your model class by renaming the fields according to the Java Naming Conventions. So you model class should look like this:



public class CommentModel 
private String comment, commentDate, profilePic, commentUser;

public CommentModel()

public CommentModel(String comment, String commentDate, String profilePic, String commentUser)
this.comment = comment;
this.commentDate = commentDate;
this.profilePic = profilePic;
this.commentUser = commentUser;


public String getComment() return comment;
public String getCommentDate() return commentDate;
public String getProfilePic() return profilePic;
public String getCommentUser() return commentUser;



See in this example, there are private fields and public getters. There is also a simpler solution, to set the value directly on public fields like this:



public class CommentModel 
public String comment, commentDate, profilePic, commentUser;



Now just remove the current data and add it again using the correct names. This solution will work only if you are in testing phase.



There is also the second approach, which is to use annotations. So if you prefer to use private fields and public getters, you should use the PropertyName annotation only in front of the getter. So your CommentModel class should look like this:



public class CommentModel 
private String comment, commentDate, profilePic, commentUser;

public CommentModel()

public CommentModel(String comment, String commentDate, String profilePic, String commentUser)
this.comment = comment;
this.commentDate = commentDate;
this.profilePic = profilePic;
this.commentUser = commentUser;


@PropertyName("Comment")
public String getComment() return comment;
@PropertyName("CommentDate")
public String getCommentDate() return commentDate;
@PropertyName("ProfilePic")
public String getProfilePic() return profilePic;
@PropertyName("CommentUser")
public String getCommentUser() return commentUser;



Don't also forget to start listening for changes.



P.S. In your class, it should be:



this.commentDate = commentDate;


and not:



commentDate = commentDate;





share|improve this answer























  • thanks for your time

    – Hashoma El-Nemr
    Jan 8 at 9:54











  • @HashomaEl-Nemr You're welcome, cheers!

    – Alex Mamo
    Jan 8 at 9:55











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53924189%2fhow-to-read-firestore-sub-collection-and-pass-it-to-firestorerecycleroptions%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














The problem in your code lies in the fact that the name of the fields in your CommentModel class are different than the name of the properties in your database. You have in your CommentModel class a field named comment but in your database I see it as Comment and this is not correct. The names must match. When you are using a getter named getComment(), Firebase is looking in the database for a field named comment and not Comment. See the lowercase c letter vs. capital letter C?



There are two ways in which you can solve this problem. The first one would be to change your model class by renaming the fields according to the Java Naming Conventions. So you model class should look like this:



public class CommentModel 
private String comment, commentDate, profilePic, commentUser;

public CommentModel()

public CommentModel(String comment, String commentDate, String profilePic, String commentUser)
this.comment = comment;
this.commentDate = commentDate;
this.profilePic = profilePic;
this.commentUser = commentUser;


public String getComment() return comment;
public String getCommentDate() return commentDate;
public String getProfilePic() return profilePic;
public String getCommentUser() return commentUser;



See in this example, there are private fields and public getters. There is also a simpler solution, to set the value directly on public fields like this:



public class CommentModel 
public String comment, commentDate, profilePic, commentUser;



Now just remove the current data and add it again using the correct names. This solution will work only if you are in testing phase.



There is also the second approach, which is to use annotations. So if you prefer to use private fields and public getters, you should use the PropertyName annotation only in front of the getter. So your CommentModel class should look like this:



public class CommentModel 
private String comment, commentDate, profilePic, commentUser;

public CommentModel()

public CommentModel(String comment, String commentDate, String profilePic, String commentUser)
this.comment = comment;
this.commentDate = commentDate;
this.profilePic = profilePic;
this.commentUser = commentUser;


@PropertyName("Comment")
public String getComment() return comment;
@PropertyName("CommentDate")
public String getCommentDate() return commentDate;
@PropertyName("ProfilePic")
public String getProfilePic() return profilePic;
@PropertyName("CommentUser")
public String getCommentUser() return commentUser;



Don't also forget to start listening for changes.



P.S. In your class, it should be:



this.commentDate = commentDate;


and not:



commentDate = commentDate;





share|improve this answer























  • thanks for your time

    – Hashoma El-Nemr
    Jan 8 at 9:54











  • @HashomaEl-Nemr You're welcome, cheers!

    – Alex Mamo
    Jan 8 at 9:55















1














The problem in your code lies in the fact that the name of the fields in your CommentModel class are different than the name of the properties in your database. You have in your CommentModel class a field named comment but in your database I see it as Comment and this is not correct. The names must match. When you are using a getter named getComment(), Firebase is looking in the database for a field named comment and not Comment. See the lowercase c letter vs. capital letter C?



There are two ways in which you can solve this problem. The first one would be to change your model class by renaming the fields according to the Java Naming Conventions. So you model class should look like this:



public class CommentModel 
private String comment, commentDate, profilePic, commentUser;

public CommentModel()

public CommentModel(String comment, String commentDate, String profilePic, String commentUser)
this.comment = comment;
this.commentDate = commentDate;
this.profilePic = profilePic;
this.commentUser = commentUser;


public String getComment() return comment;
public String getCommentDate() return commentDate;
public String getProfilePic() return profilePic;
public String getCommentUser() return commentUser;



See in this example, there are private fields and public getters. There is also a simpler solution, to set the value directly on public fields like this:



public class CommentModel 
public String comment, commentDate, profilePic, commentUser;



Now just remove the current data and add it again using the correct names. This solution will work only if you are in testing phase.



There is also the second approach, which is to use annotations. So if you prefer to use private fields and public getters, you should use the PropertyName annotation only in front of the getter. So your CommentModel class should look like this:



public class CommentModel 
private String comment, commentDate, profilePic, commentUser;

public CommentModel()

public CommentModel(String comment, String commentDate, String profilePic, String commentUser)
this.comment = comment;
this.commentDate = commentDate;
this.profilePic = profilePic;
this.commentUser = commentUser;


@PropertyName("Comment")
public String getComment() return comment;
@PropertyName("CommentDate")
public String getCommentDate() return commentDate;
@PropertyName("ProfilePic")
public String getProfilePic() return profilePic;
@PropertyName("CommentUser")
public String getCommentUser() return commentUser;



Don't also forget to start listening for changes.



P.S. In your class, it should be:



this.commentDate = commentDate;


and not:



commentDate = commentDate;





share|improve this answer























  • thanks for your time

    – Hashoma El-Nemr
    Jan 8 at 9:54











  • @HashomaEl-Nemr You're welcome, cheers!

    – Alex Mamo
    Jan 8 at 9:55













1












1








1







The problem in your code lies in the fact that the name of the fields in your CommentModel class are different than the name of the properties in your database. You have in your CommentModel class a field named comment but in your database I see it as Comment and this is not correct. The names must match. When you are using a getter named getComment(), Firebase is looking in the database for a field named comment and not Comment. See the lowercase c letter vs. capital letter C?



There are two ways in which you can solve this problem. The first one would be to change your model class by renaming the fields according to the Java Naming Conventions. So you model class should look like this:



public class CommentModel 
private String comment, commentDate, profilePic, commentUser;

public CommentModel()

public CommentModel(String comment, String commentDate, String profilePic, String commentUser)
this.comment = comment;
this.commentDate = commentDate;
this.profilePic = profilePic;
this.commentUser = commentUser;


public String getComment() return comment;
public String getCommentDate() return commentDate;
public String getProfilePic() return profilePic;
public String getCommentUser() return commentUser;



See in this example, there are private fields and public getters. There is also a simpler solution, to set the value directly on public fields like this:



public class CommentModel 
public String comment, commentDate, profilePic, commentUser;



Now just remove the current data and add it again using the correct names. This solution will work only if you are in testing phase.



There is also the second approach, which is to use annotations. So if you prefer to use private fields and public getters, you should use the PropertyName annotation only in front of the getter. So your CommentModel class should look like this:



public class CommentModel 
private String comment, commentDate, profilePic, commentUser;

public CommentModel()

public CommentModel(String comment, String commentDate, String profilePic, String commentUser)
this.comment = comment;
this.commentDate = commentDate;
this.profilePic = profilePic;
this.commentUser = commentUser;


@PropertyName("Comment")
public String getComment() return comment;
@PropertyName("CommentDate")
public String getCommentDate() return commentDate;
@PropertyName("ProfilePic")
public String getProfilePic() return profilePic;
@PropertyName("CommentUser")
public String getCommentUser() return commentUser;



Don't also forget to start listening for changes.



P.S. In your class, it should be:



this.commentDate = commentDate;


and not:



commentDate = commentDate;





share|improve this answer













The problem in your code lies in the fact that the name of the fields in your CommentModel class are different than the name of the properties in your database. You have in your CommentModel class a field named comment but in your database I see it as Comment and this is not correct. The names must match. When you are using a getter named getComment(), Firebase is looking in the database for a field named comment and not Comment. See the lowercase c letter vs. capital letter C?



There are two ways in which you can solve this problem. The first one would be to change your model class by renaming the fields according to the Java Naming Conventions. So you model class should look like this:



public class CommentModel 
private String comment, commentDate, profilePic, commentUser;

public CommentModel()

public CommentModel(String comment, String commentDate, String profilePic, String commentUser)
this.comment = comment;
this.commentDate = commentDate;
this.profilePic = profilePic;
this.commentUser = commentUser;


public String getComment() return comment;
public String getCommentDate() return commentDate;
public String getProfilePic() return profilePic;
public String getCommentUser() return commentUser;



See in this example, there are private fields and public getters. There is also a simpler solution, to set the value directly on public fields like this:



public class CommentModel 
public String comment, commentDate, profilePic, commentUser;



Now just remove the current data and add it again using the correct names. This solution will work only if you are in testing phase.



There is also the second approach, which is to use annotations. So if you prefer to use private fields and public getters, you should use the PropertyName annotation only in front of the getter. So your CommentModel class should look like this:



public class CommentModel 
private String comment, commentDate, profilePic, commentUser;

public CommentModel()

public CommentModel(String comment, String commentDate, String profilePic, String commentUser)
this.comment = comment;
this.commentDate = commentDate;
this.profilePic = profilePic;
this.commentUser = commentUser;


@PropertyName("Comment")
public String getComment() return comment;
@PropertyName("CommentDate")
public String getCommentDate() return commentDate;
@PropertyName("ProfilePic")
public String getProfilePic() return profilePic;
@PropertyName("CommentUser")
public String getCommentUser() return commentUser;



Don't also forget to start listening for changes.



P.S. In your class, it should be:



this.commentDate = commentDate;


and not:



commentDate = commentDate;






share|improve this answer












share|improve this answer



share|improve this answer










answered Dec 27 '18 at 10:32









Alex MamoAlex Mamo

49.1k83067




49.1k83067












  • thanks for your time

    – Hashoma El-Nemr
    Jan 8 at 9:54











  • @HashomaEl-Nemr You're welcome, cheers!

    – Alex Mamo
    Jan 8 at 9:55

















  • thanks for your time

    – Hashoma El-Nemr
    Jan 8 at 9:54











  • @HashomaEl-Nemr You're welcome, cheers!

    – Alex Mamo
    Jan 8 at 9:55
















thanks for your time

– Hashoma El-Nemr
Jan 8 at 9:54





thanks for your time

– Hashoma El-Nemr
Jan 8 at 9:54













@HashomaEl-Nemr You're welcome, cheers!

– Alex Mamo
Jan 8 at 9:55





@HashomaEl-Nemr You're welcome, cheers!

– Alex Mamo
Jan 8 at 9:55



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53924189%2fhow-to-read-firestore-sub-collection-and-pass-it-to-firestorerecycleroptions%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현