如何向特定类添加行?

时间:2014-09-23 17:17:22

标签: android parse-platform

这是我的代码:

    ParseObject testObject = new ParseObject("TestObject");
    testObject.put("col1", "sharon");
    testObject.put("col2", "michael");
    testObject.put("col3", "john");
    try {
        testObject.save();
    } catch (ParseException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }

    ParseObject testObject2 = new ParseObject("TestObject");
    testObject.put("col1", "ron");
    testObject.put("col2", "ted");
    testObject.put("col3", "dave");
    try {
        testObject2.save();
    } catch (ParseException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }

问题是 - 当我保存“TestObject”类的第二个对象时,它在parse.com的数据浏览器中有未定义的值。

提前致谢。

1 个答案:

答案 0 :(得分:1)

你有一些错别字。在第二个对象创建中,您使用puttestObject代替testObject2

ParseObject testObject2 = new ParseObject("TestObject");
testObject2.put("col1", "ron");  //This line had a typo
testObject2.put("col2", "ted");  //This line had a typo
testObject2.put("col3", "dave"); //This line had a typo
try {
    testObject2.save();
} catch (ParseException e1) {
    // TODO Auto-generated catch block
    e1.printStackTrace();
}