Android file handling code working in marshmallow but not in Kitkat -


the same code mentioned below works in marshmallow doesn't work in kitkat.

the code taking data edittext , saving in internal storage. there 2 buttons save , load save onclick - save, load onclick - load .unable find problem. please help

edittext edittext;     button save, load;      @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_file_test);         edittext = (edittext) findviewbyid(r.id.input);         save = (button) findviewbyid(r.id.bsave);         load = (button) findviewbyid(r.id.bload);     }      public void save(view v) {         string text = edittext.gettext().tostring();         file file = null;         fileoutputstream fileoutputstream = null;         try {             file = getfilesdir();             log.e("aug", file.tostring());             fileoutputstream = openfileoutput("mytext.txt", context.mode_private);             fileoutputstream.write(text.getbytes());         } catch (filenotfoundexception e) {          } catch (ioexception e) {             e.printstacktrace();         }         {             if(fileoutputstream!=null){                 try {                     fileoutputstream.close();                 } catch (ioexception e) {                     e.printstacktrace();                 }             }         }         toast.maketext(getapplicationcontext(), file+"/mytext.txt", toast.length_long).show();     }      public void load(view v){         try {             fileinputstream fileinputstream = openfileinput("mytext.txt");             int read = -1;             stringbuffer stringbuffer = new stringbuffer();             while ((read=fileinputstream.read())!=-1){                 stringbuffer.append((char)read);             }             log.e("aug load data", stringbuffer.tostring());         } catch (filenotfoundexception e) {             e.printstacktrace();         } catch (ioexception e) {             e.printstacktrace();         }     } 


Comments