@Override
 public void onPause() {
   userDAO.close();
   super.onPause();
 }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View view = inflater.inflate(R.layout.fragment_leader, container, false);

    // open database
    userDAO = new UserDAO(getContext());
    userDAO.open();

    name = (EditText) view.findViewById(R.id.login_name);
    nickname = (EditText) view.findViewById(R.id.login_nickname);
    password = (EditText) view.findViewById(R.id.login_program_password);
    repassword = (EditText) view.findViewById(R.id.login_program_confirmpassword);
    program = (EditText) view.findViewById(R.id.login_program_type);
    chapter = (EditText) view.findViewById(R.id.login_program_chapter);
    host = (EditText) view.findViewById(R.id.login_program_host);

    // do the button function
    btn = (Button) view.findViewById(R.id.login_btn);
    btn.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {

            // Reset Errors
            name.setError(null);
            nickname.setError(null);
            password.setError(null);
            repassword.setError(null);
            program.setError(null);
            chapter.setError(null);
            host.setError(null);

            boolean cancel = false;
            View focusView = null;

            // TODO transformal em uppercase() o Program, Chapter & Host

            // Store values at the time of the login attempt.
            final String mName = name.getText().toString();
            final String mNickname = nickname.getText().toString();
            final String mPassword = password.getText().toString();
            final String mRePassword = repassword.getText().toString();
            final String mProgram = program.getText().toString();
            final String mChapter = chapter.getText().toString();
            final String mHost = host.getText().toString();

            if (TextUtils.isEmpty(mName)) {
              name.setError(getString(R.string.error_field_required));
              focusView = name;
              cancel = true;
            }
            if (TextUtils.isEmpty(mNickname)) {
              nickname.setError(getString(R.string.error_field_required));
              focusView = nickname;
              cancel = true;
            }
            if (TextUtils.isEmpty(mPassword)) {
              password.setError(getString(R.string.error_field_required));
              focusView = password;
              cancel = true;
            }
            if (TextUtils.isEmpty(mRePassword)) {
              repassword.setError(getString(R.string.error_field_required));
              focusView = repassword;
              cancel = true;
            }
            if (TextUtils.isEmpty(mProgram)) {
              program.setError(getString(R.string.error_field_required));
              focusView = program;
              cancel = true;
            }
            if (TextUtils.isEmpty(mChapter)) {
              chapter.setError(getString(R.string.error_field_required));
              focusView = chapter;
              cancel = true;
            }
            if (TextUtils.isEmpty(mHost)) {
              host.setError(getString(R.string.error_field_required));
              focusView = host;
              cancel = true;
            }

            if (cancel) {
              // There was an error; don't attempt login and focus the first
              // form field with an error.
              focusView.requestFocus();
            } else {

              User user =
                  new User(mName, mNickname, mPassword, mRePassword, mProgram, mChapter, mHost, 1);
              userDAO.createUser(user);

              // list all users
              Log.d("LeaderFragment", "User: "******"Account created!!!", Toast.LENGTH_SHORT).show();
              Intent intent = new Intent(getContext(), HomeActivity.class);
              intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
              startActivity(intent);
              getActivity().finish();
            }
          }
        });
    return view;
  }
 @Override
 public void onResume() {
   userDAO.open();
   super.onResume();
 }