Parse.com保存空模型

时间:2014-10-08 09:54:32

标签: android parse-platform

我是一名Android开发人员,但在Parse开始。 我想在Parse中保存一个模型。 以下是我的代码: -

申请: -

    ParseObject.registerSubclass(ParseProduct.class);
    Parse.enableLocalDatastore(getApplicationContext());
    Parse.initialize(this, Constant.parseApplicationId, Constant.parseClientKey);

    ParseUser.enableAutomaticUser();
    ParseACL defaultACL = new ParseACL();   

    // If you would like all objects to be private by default, remove this line.
    defaultACL.setPublicReadAccess(true);

    ParseACL.setDefaultACL(defaultACL, true);

模特课: -

public ParseProduct(){

}

public String getProductId() {
    return getString("productId");
}

public void setProductId(String id) {
    put("productId", id);
} 

public String getName() {
    return getString("productName");
}

public void setName(String name) {
    put("productName", name);
} 

public String getDescription() {
    return getString("productDescription");
}

public void setDescription(String description) {
    put("productDescription", description);
} 

public String getSku() {
    return getString("productSku");
}

public void setSku(String sku) {
    put("productSku", sku);
} 

public String getModelNo() {
    return getString("productModelNo");
}
public void setModelNo(String modelNo) {
    put("productModelNo", modelNo);
}

public String getShape() {
    return getString("productShape");
}
public void setShape(String shape) {
    put("productShape", shape);
}

public String getColor() {
    return getString("productColor");
}
public void setColor(String color) {
    put("productColor", color);
}

public String getLowStock() {
    return getString("productLowStock");
}
public void setLowStock(String lowStock) {
    put("productLowStock", lowStock);
}

public String getDeadStock() {
    return getString("productDeadStock");
}
public void setDeadStock(String deadStock) {
    put("productDeadStock", deadStock);
}

public int getSellprice() {
    return getInt("productSellPrice");
}
public void setSellprice(int sellprice) {
    put("productSellPrice", sellprice);
}

public int getCostPrice() {
    return getInt("productCostPrice");
}
public void setCostPrice(int costPrice) {
    put("productCostPrice", costPrice);
}

public int getQty() {
    return getInt("productQty");
}
public void setQty(int qty) {
    put("productQty", qty);
}

public int getQuantityPurchase() {
    return getInt("productQtyPurchase");
}

public void setQuantityPurchase(int quantityPurchase) {
    put("productQtyPurchase", quantityPurchase);
}

public int getGravity() {
    return getInt("productGravity");
}

public void setGravity(int gravity) {
    put("productGravity", gravity);
}

public long getTimestamp() {
    return getInt("productTimestamp");
}

public void setTimestamp(long timestamp) {
    put("productTimestamp", timestamp);
}

这是我点击保存按钮时的代码: -

    ParseProduct product = new ParseProduct();
    product.setName("Product Name");
    product.setDescription("Description");
    product.setSku("sku");
    product.setModelNo("model");
    product.setShape("Circle");
    product.setColor("Black");
    product.setLowStock("12");
    product.setDeadStock("12");
    product.setSellprice(120);
    product.setCostPrice(110);
    product.setQty(12);
    product.saveInBackground(saveCallback);

但它总是保存一个空行。

0 个答案:

没有答案