How can I create method for passing values from Activity to other components : <p>I need the <code>chapterId</code> and <code>lessonId</code> value in <code>Tablayout</code> fragments .</p>

<p>one of the solution to send data from activity to fragment is sending value with public method in activity and create a new instance in fragment and give the value in fragments .</p>

<p>I have This activity where i get bundle in that .</p>

<pre><code> public class DetailActivity extends AppCompatActivity {

        private String chapterId;
        private String lessonId;


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

            getBundle();

        }

        private void getBundle() {
            Bundle bundle = getIntent().getExtras();

            if (bundle != null) {
                chapterId = bundle.getString("CHAPTERID");
                lessonId = bundle.getString("LESSONID");
            }
        }

      ========  Method for sending data to other Activities and Fragments=====
        public String  getId(){

        }

    }
</code></pre>

<p>Now my question is how can i write this method . Thanks</p>
