java 从 Parse.com 中的对象 ID 获取数据
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25622991/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Getting data from object Id in Parse.com
提问by userAndroid
I am facing some problem related to parse.com I want to fetch the data for a perticular objectId...I have used following code to get the data but seems it is depreciated..as it returned following exception
我面临一些与 parse.com 相关的问题我想获取特定 objectId 的数据...我使用以下代码来获取数据,但似乎已折旧...因为它在异常后返回
no results found for query
I have used following code to get the data form objectId:
我使用以下代码来获取数据表单 objectId:
ParseQuery<ParseObject> query = new ParseQuery<ParseObject>("User");
query.getInBackground("U8mCwTHOaC", new GetCallback() {
public void done(ParseObject object, ParseException e) {
Log.d(">>>", "0000>>>" +objid);
dlg.dismiss();
if (e == null) {
// object will be your game score
Log.d(">>",">>"+object);
} else {
// something went wrong
Log.d(">>",">>"+e);
}
}
});
Here "U8mCwTHOaC" is my objectId,I want to fetch the row of this objectId.Thanks in advance..
这里“U8mCwTHOAC”是我的objectId,我想获取这个objectId的行。提前谢谢..
回答by John
if you want to get data from user table.
如果你想从用户表中获取数据。
ParseQuery<ParseObject> query = ParseQuery.getQuery("_User");
query.whereEqualTo("objectId","U8mCwTHOaC");
query.findInBackground(new FindCallback<ParseObject>() {
public void done(List<ParseObject> objects, ParseException e) {
if (e == null) {
// row of Object Id "U8mCwTHOaC"
} else {
// error
}
}
});
if you want the row of current user
如果你想要当前用户的行
ParseQuery<ParseObject> query = ParseQuery.getQuery("_User");
query.whereEqualTo("objectId",ParseUser.getCurrentUser().getObjectId());
query.findInBackground(new FindCallback<ParseObject>() {
public void done(List<ParseObject> objects, ParseException e) {
if (e == null) {
// row of Object Id "Current USer"
} else {
// error
}
}
});