如果代码存在于parse.com中怎么办?

时间:2014-10-13 11:45:23

标签: java android parse-platform

我有一个问题,我在parse.com的“VerificationCode”db中有这个结构:

enter image description here

当有人在我的应用程序中插入代码时,它会自动在“attachedUser”列中添加本地存储的用户的ID,并将其称为“ParseInstallObject.codigo2”,并获取用户的ID,例如在textview等中看到它

问题是我想检查用户ID是否存在于解析中;如果存在则做某事或不存在做另一件事。

我使用了我在parse.com文档中看到的代码,但它始终显示代码存在。这是我的代码:

 ParseQuery<ParseObject> query2 = ParseQuery.getQuery("VerificationCode");
    query2.whereEqualTo("attachedUser", ParseInstallObject.codigo2);
    query2.findInBackground(new FindCallback<ParseObject>() {
        public void done(List<ParseObject> scoreList, ParseException e) {
            if (e == null) {
                comprobar.setText("exist");
                comprobar2.setText("exist");

            } else {
                comprobar.setText("no exist");
                comprobar2.setText("no exist");

            }
        }
    });

如何查看用户是否拥有有效代码?

1 个答案:

答案 0 :(得分:0)

e==null means that the call was successfully completed by the server. It does not imply that the user exists or not.
if(e==null){
if(scoreList == null || scoreList.isEmpty()){
 // The user does not exist.
}else{
// the user exists.
}
}else {
// You have an exception (like HTTPTimeout, etc). Handle it as per requirement.
}