简体   繁体   中英

Parse.com - how to store custom objects

I'd like to store my Android application's data in a Parse.com database, but I'm having trouble right now. I'm trying to save my own 'Parent' class. The Parent class has different attributes. Right now I'd like to store these:

private String email;
private String password;

There are more attributes, but atm I'm not filling em up during runtime, will do so later when I know the whole idea works.

I am aware of the classes ParseUser and ParseObject, a user and an object class of Parse, which can be used to store data to their DB. Now my first approach was to let my own Parent class inherit from Parse's ParseUser or ParseObject. That way my class would have access to the Parse's methods, while maintaining my own attributes and methods. I tried that and I don't think it works. It gave a vague error, with no clear error message. (click on the next link for a pic http://i.imgur.com/orkmjXO.png )

Right now my Userr class inherits from ParseObject. Well not directly, but it has access to ParseObejct's methods. the hierarchy goes like this ParseObject -> (mine) User -> (mine) Parent. Below I pasted the code I use at the point of saving.

Parent user = new Parent();
user.setEmail(mEmail);
user.setWachtwoord(mPassword);

user.put(mEmail, user);
user.saveInBackground();

Could anyone help me and tell me how I can store my own classes in Parse? Any kind of help would be appreciated, like possible causes and such. Thanks!

as per the parse docs, looks like ParseObject is like a Map.

refer: https://www.parse.com/apps/quickstart#parse_data/mobile/android/native/new

ParseObject testObject = new ParseObject("TestObject");
testObject.put("foo", "bar");
testObject.saveInBackground();

so I guess, in you case this would translate to:

user.put("mEmail", "user1");
user.saveInBackground();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM