Reputation: 304
I have a class in parse.com called Messages. I have created a column called sent of type string which stores the object-id of the user to whom the message has to be sent. In my android app I want to retrieve the messages of the current user. But my app does not show any messages.
This is how I'm implementing it-
public void done(List<ParseObject> postList, ParseException e) {
setProgressBarIndeterminateVisibility(false);
if (e == null) {
// If there are results, update the list of posts
// and notify the adapter
posts.clear(); //posts is a list of <TextMessage>
//TextMessage is a class which holds the details of Messages (parse object)
for (ParseObject msg : postList) {
if(msg.getParseUser("sent")==ParseUser.getCurrentUser())
{
TextMessage note = new TextMessage(msg.getObjectId());
posts.add(note);
}
}
((ArrayAdapter<TextMessage>) getListAdapter()).notifyDataSetChanged();
}
I can't understand why the if conditions are not being implemented, what am I doing wrong. How else can I retrieve the string in the sent column? Feel free to ask for any more information required.
Upvotes: 1
Views: 727
Reputation: 6739
I am not android expert but I think your issue is :
If you care comparing two strings, you must use equals()
not ==
Change ==
to equals()
everything works
Note: ==
checks the reference to the object are equal .
Note: equals()
This method compares this string to the specified object. The result is true if and only if the argument is not null and is a String object that represents the same sequence of characters as this object
Upvotes: 1