Hello,
I’m trying to get the name of another user using the following code, but I am getting the error “Entity with ID ___ not found”.
Slightly irrelevant but might help: In the property “friends”, I am storing the friends list of each user as a JSON. The code in handleResponse is me adding each user to the other’s friends list.
Backendless.UserService.findById(searchUser, new AsyncCallback<BackendlessUser>() {
@Override
public void handleResponse(BackendlessUser response) {
String newFriend=response.getProperty(“username”).toString();
String user1Name=currentUser.getProperty(“username”).toString();
ArrayList<String> user2Friends=new ArrayList<String>();
JsonParser parser = new JsonParser();
JsonArray user2JSONArray= parser.parse(newFriend).getAsJsonArray();
for(JsonElement user2JsonElement: user2JSONArray){
JsonObject json= user2JsonElement.getAsJsonObject();
String user2Friend=json.get(“friend”).getAsString();
user2Friends.add(user2Friend);
}
user2Friends.add(user1Name);
JsonArray uploadUser2Friends= new JsonArray();
for(String friend: user2Friends){
JsonObject user2FriendJSON=new JsonObject();
user2FriendJSON.addProperty(“friends”, friend);
uploadUser2Friends.add(user2FriendJSON);
}
String user2UploadFriendsString= uploadUser2Friends.toString();
response.setProperty(“friends”,user2UploadFriendsString);
friends.add(newFriend);
}
@Override
public void handleFault(BackendlessFault fault) {
Toast.makeText(getApplicationContext(), fault.getMessage(), Toast.LENGTH_SHORT).show();
}
});