问题
I am creating a twitter like app where we can follow other users and read their tweets.
ParseUser.getCurrentUser().getList("isFollowing").remove(users.get(position));
List<String> tmpUsers=ParseUser.getCurrentUser().getList("isFollowing");
ParseUser.getCurrentUser().remove("isFollowing");
ParseUser.getCurrentUser().put("isFollowing", tmpUsers);
The above code runs when user wants to unfollow.
I had a doubt in:
ParseUser.getCurrentUser().getList("isFollowing").remove(users.get(position));
List<String> tmpUsers=ParseUser.getCurrentUser().getList("isFollowing");
when we are using ParseUser.getCurrentUser().getList("isFollowing").remove(users.get(position));
are we downloading the list from the database and removing the element locally?
When we run List<String> tmpUsers=ParseUser.getCurrentUser().getList("isFollowing");
are we downloading the list again or are we getting the list which has users.get(position)
removed?
回答1:
You are not "downloading" the list in any of these lines. You are accessing the list that is already cached in your device. In order to fetch the latest data you need to use:
ParseUser.getCurrentUser().fetch();
来源:https://stackoverflow.com/questions/65312284/parseuser-getlist-in-parse-database