Android Parse.com正在将parseObject添加到数据库异常:应为数字,但得到一个数组

Android Parse.com正在将parseObject添加到数据库异常:应为数字,但得到一个数组,android,arrays,parse-platform,android-studio,Android,Arrays,Parse Platform,Android Studio,我有以下代码: buttonAddAlert.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if(AddAlert.this.isOnline()){ if(busNumber.getText().toString().isEmpty(

我有以下代码:

buttonAddAlert.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                if(AddAlert.this.isOnline()){   
                    if(busNumber.getText().toString().isEmpty() || description.getText().toString().isEmpty()){
                        Toast.makeText((Context)(AddAlert.this.getBaseContext()), (CharSequence)("Please fill all the fields!"), (int)(Toast.LENGTH_SHORT)).show();
                    }
                    else {
                        ParseObject parseObject = new ParseObject("AlertsClass");
                        parseObject.add("BusNumber", Integer.parseInt(busNumber.getText().toString()));
                        parseObject.add("Description", description.getText().toString());
                        //requestLocation();
                        parseObject.add("Coordinates", new ParseGeoPoint(currentLatitude, currentLongitude));

                        parseObject.saveEventually(new SaveCallback() {

                            @Override
                            public void done(ParseException e) {
                                Intent recentSightingsPageIntent = new Intent(AddAlert.this, RecentSightings.class);
                                startActivity(recentSightingsPageIntent);
                            }
                        });
                    }
                }
                else{
                    Toast.makeText((Context)(AddAlert.this.getBaseContext()), (CharSequence)("Your internet connection is offline"), (int)(Toast.LENGTH_SHORT)).show();
                }
            }
        });
在调试代码时,当代码到达“public void done(ParseException e)”时,异常(e)打印:

com.parse.ParseException:键BusNumber的类型无效,应为数字,但得到数组

我有点被蒙住了眼睛,我不明白为什么我会收到这个错误,因为我正在将文本从EditText转换为int,但它仍然说它是一个数组


谢谢你抽出时间

解决了它。问题是我使用的是parseObject.add(用于数组)。要将单个值放入数据库,需要使用parseObject.put(用于单个项)。否则你会得到我的例外。我在这里写这篇文章,也许有人会看到同样的问题


干杯

解决了它。问题是我使用的是parseObject.add(用于数组)。要将单个值放入数据库,需要使用parseObject.put(用于单个项)。否则你会得到我的例外。我在这里写这篇文章,也许有人会看到同样的问题


干杯

不应使用
addObject:forKey:
。解析对象实际上是字典,因此请尝试使用
setObject:forKey:

您不应该使用
addObject:forKey:
。parse对象实际上是dictionary,因此请尝试使用
setObject:forKey:

如果在此之前创建一个int变量,然后使用该int变量作为值,会发生什么情况确定,将尝试!非常感谢。不,我创建了int变量,但得到了相同的错误。请尝试使用Integer.valueOf(busNumber.getText().toString());如果在此之前创建一个int变量,然后将该int变量用作值,会发生什么情况?OK,将尝试!非常感谢。不,我创建了int变量,但得到了相同的错误。请尝试使用Integer.valueOf(busNumber.getText().toString());