1

I have an editor activity where user can make changes in edit Text and in Radio buttons. i had put FAB button in editor activity "when user click on fab all changes should be save" but i don't know how i can do this. data i am getting from POJO. Thanks in advance.

    btnSave = (FloatingActionButton) findViewById(R.id.fab);
            radioGroup1 = (RadioGroup) findViewById(R.id.radio_group_broadcast);
            rbPub = (RadioButton)findViewById(R.id.radio_button_public);
            rbPri = (RadioButton)findViewById(R.id.radio_button_private);
            rbUnl = (RadioButton)findViewById(R.id.radio_button_unlisted);
            rbOnl = (RadioButton)findViewById(R.id.radio_button_logged_only);

    if (videoDetail.getBroadcast().contains("public")) {
                radioGroup1.check(R.id.radio_button_public);
            }
            else if (videoDetail.getBroadcast().contains("private")) {
                radioGroup1.check(R.id.radio_button_private);
            }
            else if (videoDetail.getBroadcast().contains("unlisted")) {
                radioGroup1.check(R.id.radio_button_unlisted);
            }
            else if (videoDetail.getBroadcast().contains("loggedin")) {
                radioGroup1.check(R.id.radio_button_logged_only);
            }

    radioGroup1.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
                @Override
                public void onCheckedChanged(RadioGroup group, int checkedId) {

                    int selectedId = radioGroup1.getCheckedRadioButtonId();
                    rbPub = (RadioButton)findViewById(selectedId);
                    Toast.makeText(VideoEditorActivity.this, "Broadcast " + rbPub.getText().toString()
                    ,Toast.LENGTH_SHORT).show();
                }
           });

btnSave.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                //i think something need to do here
            }
        });
iam john
  • 11
  • 3
  • You could use "onSaveInstanceState(Bundle savedInstanceState)", read more about it here http://stackoverflow.com/questions/151777/saving-android-activity-state That's just one of the ways. – CJR Nov 19 '16 at 12:34
  • 1
    You can save data in a SQLite database, you can save preferences in SharedPreferences. There is ample documentation for both on the Android Developer web site. – Christine Nov 19 '16 at 14:15
  • you can also serialize data and save to file, e.g. [`Context.openFileOutput()`](https://developer.android.com/reference/android/content/Context.html#openFileOutput(java.lang.String,%20int)) – nandsito Nov 19 '16 at 16:42

0 Answers0