protected void onStop() { super.onStop(); App42API.initialize( getApplicationContext(), "33febecb03a579e972755eccde307dd94a279b5cfe348f845b8762f8e3feb2d6", "b5be405b4e76d40a94cdc01250311205b5a7c7b2dc4d003714f24d0df3e219f8"); final UserService userService = App42API.buildUserService(); App42API.setOfflineStorage(true); String username = mGameSettings.getString(GAME_PREFERENCES_USERNAME, null); String schl = mGameSettings.getString(GAME_PREFERENCES_SCHOOL, null); App42API.setLoggedInUser(username); String p = mGameSettings.getString(GAME_PREFERENCES_PASSWORD, null); String strEmailToSave = mGameSettings.getString(GAME_PREFERENCES_EMAIL, null); String pwd = p; String emailId = strEmailToSave; /* This will create user in App42 cloud and will return created User object in onSuccess callback method */ userService.createUser( username, pwd, emailId, new App42CallBack() { public void onSuccess(Object response) { User user = (User) response; System.out.println("userName is " + user.getUserName()); System.out.println("emailId is " + user.getEmail()); } public void onException(Exception ex) { System.out.println("Exception Message" + ex.getMessage()); } }); User userObj = new User(); userObj.setUserName(username); Profile profile = userObj.new Profile(); Date date = new Date(); /* returns the current date object.User can set any date */ profile.setFirstName(username); profile.setLine1(schl); /* Following will create user profile and returns User object which has profile object inside in onSuccess callback method */ userService.createOrUpdateProfile( userObj, new App42CallBack() { public void onSuccess(Object response) { User user = (User) response; System.out.println("userName is " + user.getUserName()); System.out.println("School is " + user.getProfile().getLine1()); } public void onException(Exception ex) { System.out.println("Exception Message" + ex.getMessage()); } }); Toast.makeText(getApplicationContext(), "User Settings Saved", Toast.LENGTH_SHORT).show(); UtilSettings.this.finish(); }