Skip to content Skip to sidebar Skip to footer

Objectid In Parse Is Always Null

In my Activity I init the Parse service: Parse.enableLocalDatastore(getApplicationContext()); ParseObject.registerSubclass(Person.class); ParseObject.registerSubclass(Area.class);

Solution 1:

The problem is getString("objectId");. You must not implement default Parse Column getters/setters.

You can get it with getObjectId() which has already been implemented in ParseObject. Also to get updatedAt, createdAt and some other default Parse column, you have to use their own Getters such as getUpdatedAt() and getCreatedAt().

At the below, I removed your objectId getter implementation. You should implement only your own column fields.

@ParseClassName("Area")
publicclassAreaextendsParseObject {    
    publicstaticParseQuery<Area> getQuery() {
        returnParseQuery.getQuery(Area.class);
    }

    publicStringgetName() {
        returngetString("name");
    }

    publicvoidsetName(String name) {
        put("name", name);
    }
}

Solution 2:

Update

You have included a getter for objectId in your subclass. This is already accessible from the parent class and should not overridden.

Old answer

The problem is probably that objects in local datastore does not have an objectId until it has been saved remotely to Parse. Only then does it get an objectId.

You need to make sure your objects have been saved remotely OR you need to pin objects locally before querying them. In the case of pinning, you cannot access the objectId unless it has also been saved remotely.

Solution 3:

Remove your empty constructor or call super() within it.

Post a Comment for "Objectid In Parse Is Always Null"