I'm new to Parse and am trying to save a new row to my table (on Android). I've made sure that all my columns that I want to add to are of type String, as well as my objects.
我是Parse的新手,我正在尝试将新行保存到我的桌面上(在Android上)。我已经确保我要添加的所有列都是String类型,以及我的对象。
Here is the code that I use to save it to the database:
这是我用来将其保存到数据库的代码:
ParseObject accountObj = new ParseObject("networks");
accountObj.add("token", token);
accountObj.add("parse_user", parseUser);
accountObj.add("type", "facebook");
accountObj.add("fb_profile_url", profileUrl);
accountObj.saveInBackground(); // expected type string but got array
Could somebody please explain what is going on? I've tried deleting the class and starting fresh, but it just gives me the same answer.
有人可以解释一下发生了什么吗?我已经尝试删除课程并重新开始,但它只是给了我相同的答案。
1 个解决方案
#1
I'm not sure what ParseObject.add() does, but the docs say to use ParseObject.put() instead.
我不确定ParseObject.add()是做什么的,但文档说使用ParseObject.put()代替。
From the docs:
来自文档:
ParseObject gameScore = new ParseObject("GameScore");
gameScore.put("score", 1337);
gameScore.put("playerName", "Sean Plott");
gameScore.put("cheatMode", false);
gameScore.saveInBackground();
Source: https://parse.com/docs/android/guide#objects-saving
This could solve your issue, as perhaps the .add() function is used to add objects to an array (hence the array error).
这可以解决您的问题,因为.add()函数可能用于向数组添加对象(因此数组错误)。
#1
I'm not sure what ParseObject.add() does, but the docs say to use ParseObject.put() instead.
我不确定ParseObject.add()是做什么的,但文档说使用ParseObject.put()代替。
From the docs:
来自文档:
ParseObject gameScore = new ParseObject("GameScore");
gameScore.put("score", 1337);
gameScore.put("playerName", "Sean Plott");
gameScore.put("cheatMode", false);
gameScore.saveInBackground();
Source: https://parse.com/docs/android/guide#objects-saving
This could solve your issue, as perhaps the .add() function is used to add objects to an array (hence the array error).
这可以解决您的问题,因为.add()函数可能用于向数组添加对象(因此数组错误)。