Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android

How to add more fields in parse ?

I want to add more fields to user table in parse e.g weight, height, Date of birth.

Thanks

package com.example.android.burnit;

import android.os.Bundle; import android.support.v7.app.ActionBarActivity; import android.view.Menu;

import com.parse.ParseUser; import com.parse.SignUpCallback;

public class SignUp extends ActionBarActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.sign_up);

    ParseUser user = new ParseUser();
    user.setUsername("my NAME");
    user.setPassword("my PaSS");
    user.setEmail("email@hotmail.com");

// other fields can be set just like with ParseObject user.put("phone", "650-253-0000");

    user.signUpInBackground(new SignUpCallback() {

        public void done(com.parse.ParseException e) {
            if (e == null) {
                // Hooray! Let them use the app now.
            } else {
                // Sign up didn't succeed. Look at the ParseException
                // to figure out what went wrong
            }
        }
    });
}





@Override
public boolean onCreateOptionsMenu (Menu menu){
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_sign_up, menu);
    return true;
}

}

1 Answer

Hello,

To add more fields to a table in parse, you use the .put method. this method requires two parameters, the first you can think of as the column name of the table, and the second being the value of the column.

user.put("column_name", "value");

So for your example of wanting to store the weight of a user, I would envision something like this:

user.put("weight", "225");

Thanks Brett :)