Save data from various fragments

0

I have a slide (using the material-intro lib) that has several fragments, I need to save the data that is typed in these edittext fragments when I close this slide, I'm trying via try but I'm not getting it.

As I'm saving in the intent in the fragment:

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    txtnome = view.findViewById(R.id.txt_nome);
    final Usuario user = new Usuario();

    txtnome.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
            Intent intent = new Intent();
            intent.putExtra("nome",txtnome.getText().toString());
            validado = !txtnome.getText().toString().isEmpty();
        }

        @Override
        public void afterTextChanged(Editable editable) {

        }
    });
}

As I'm trying to look into the actvity that opens after closing the slides:

 @Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == REQUEST_CODE_INTRO) {
        if (resultCode == RESULT_OK) {
            Intent intent = new Intent();

            String nome = intent.getStringExtra("nome");
            String altura = intent.getStringExtra("altura");
            Toast.makeText(this, "Nome: " + nome, Toast.LENGTH_SHORT).show();
            Toast.makeText(this, "Altura: " + altura, Toast.LENGTH_SHORT).show();
            PreferenceManager.getDefaultSharedPreferences(this).edit()
                    .putBoolean(PREF_KEY_FIRST_START, false)
                    .apply();
        } else {

they return null

    
asked by anonymous 15.11.2017 / 13:39

0 answers