package Ġcom . sh ub ham . scoped storage _ android Ċ Ċ import Ġandroid . os . Bundle Ċ import Ġandroidx . appcompat . app . AppCompatActivity Ċ import Ġandroidx . databinding . Data Binding Util Ċ import Ġandroidx . view pager 2 . widget . ViewPager 2 Ċ import Ġcom . google . android . material . tabs . Tab Layout Mediator Ċ import Ġcom . sh ub ham . scoped storage _ android . adapter . ViewPager 2 Adapter Ċ import Ġcom . sh ub ham . scoped storage _ android . databinding . Activity Main Binding Ċ import Ġcom . sh ub ham . scoped storage _ android . fragments . Internal Storage Fragment Ċ import Ġcom . sh ub ham . scoped storage _ android . fragments . Shared Storage Fragment Ċ Ċ class ĠMainActivity Ġ: ĠAppCompatActivity () Ġ{ ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġbinding : ĠActivity Main Binding ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġview Pager Adapter : ĠView Pager 2 Adapter ĊĊĠĠĠ Ġprivate Ġval Ġtab Name List Ġ= ĠArrayList < String >() ĊĊĠĠĠ Ġoverride Ġfun ĠonCreate ( savedInstanceState : ĠBundle ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . onCreate ( savedInstanceState ) ĊĠĠĠĠĠĠĠ Ġbinding Ġ= ĠData Binding Util . set ContentView ( this , ĠR . layout . activity _ main ) ĊĊĠĠĠĠĠĠĠ Ġbinding . view Pager 2 . orientation Ġ= ĠView Pager 2 . OR IENTATION _ HORIZONTAL ĊĊĠĠĠĠĠĠĠ Ġview Pager Adapter Ġ= ĠView Pager 2 Adapter ( support FragmentManager , Ġlifecycle ) ĊĊĠĠĠĠĠĠĠ Ġview Pager Adapter . add Fragment ( Shared Storage Fragment ()) ĊĠĠĠĠĠĠĠ Ġview Pager Adapter . add Fragment ( Internal Storage Fragment ()) ĊĊĠĠĠĠĠĠĠ Ġtab Name List . add (" Shared ĠStorage ") ĊĠĠĠĠĠĠĠ Ġtab Name List . add (" Internal ĠStorage ") ĊĊĠĠĠĠĠĠĠ Ġbinding . view Pager 2 . adapter Ġ= Ġview Pager Adapter ĊĊĠĠĠĠĠĠĠ ĠTab Layout Mediator ( binding . tab Layout , Ġbinding . view Pager 2 ) Ġ{ Ġtab , Ġposition Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġtab . text Ġ= Ġtab Name List [ position ] ĊĠĠĠĠĠĠĠ Ġ}. attach () ĊĊĠĠĠ Ġ} Ċ Ċ } ĊĊĊĊĊĊĊĊĊĊĊĊĊĊĊĊĊĊĊĊĊĊĊĊĊĊĊĊĊĊĊĊ ĊĊĊĊ