package Ġcom . the app hide away . autom ate with python . Chapter s Ċ Ċ import Ġandroid . support . v 7 . app . AppCompatActivity Ċ import Ġandroid . os . Bundle Ċ import Ġandroid . os . Environment Ċ import Ġandroid . widget . Toast Ċ import Ġcom . cha quo . python . Python Ċ import Ġcom . the app hide away . autom ate with python . R Ċ import Ġkotlinx . android . synt hetic . main . activity _ chapter _ n ine .* Ċ import Ġjava . io . File Ċ Ċ class ĠChapter N ine Activity Ġ: ĠAppCompatActivity () Ġ{ ĊĊĠĠĠ Ġval Ġpy Ġ= ĠPython . getInstance () ĊĠĠĠ Ġvar Ġpy Class Ġ= Ġpy . getModule (" Chapter N ine ") ĊĠĠĠ Ġvar Ġfile To Read And Write : ĠFile ? Ġ= Ġnull ĊĊĠĠĠ Ġoverride Ġfun ĠonCreate ( savedInstanceState : ĠBundle ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . onCreate ( savedInstanceState ) ĊĠĠĠĠĠĠĠ ĠsetContentView ( R . layout . activity _ chapter _ n ine ) ĊĊĠĠĠĠĠĠĠ Ġrename _ button . setOnClickListener Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġvar Ġrename Result Ġ= Ġpy Class . call Attr (" rename _ file ", Ġget Old Filename (), Ġget New Filename ()) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠToast . makeText ( this , Ġrename Result . toString (), ĠToast . LENGTH _ LONG ). show () ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġdelete _ button . setOnClickListener Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġvar Ġdelete Result Ġ= Ġpy Class . call Attr (" delete _ file ", Ġget New Filename ()) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠToast . makeText ( this , Ġdelete Result . toString (), ĠToast . LENGTH _ LONG ). show () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġget Document Storage Path (): ĠFile Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġpath Ġ= ĠEnvironment . get External Storage Public Directory ( Environment . DIRECTORY _ DOCUMENT S ) ĊĠĠĠĠĠĠĠ Ġif Ġ(! path . mkdir s ()) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġpath . mkdir s () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġreturn Ġpath ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġget Old Filename (): ĠFile Ġ{ ĊĠĠĠĠĠĠĠ Ġfile To Read And Write Ġ= ĠFile ( getDocument Storage Path (), Ġ"${ old _ file _ edit _ text . text }. txt ") ĊĊĠĠĠĠĠĠĠ Ġreturn Ġfile To Read And Write Ġas ĠFile ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġget New Filename (): ĠFile Ġ{ ĊĠĠĠĠĠĠĠ Ġfile To Read And Write Ġ= ĠFile ( getDocument Storage Path (), Ġ"${ new _ name _ edit _ text . text }. txt ") ĊĊĠĠĠĠĠĠĠ Ġreturn Ġfile To Read And Write Ġas ĠFile ĊĠĠĠ Ġ} Ċ } Ċ