save - Writing to File Internal Storage Android -


given code:

final string dir = environment.getexternalstoragepublicdirectory(environment.directory_documents) + "/";     string file = dir + "info.txt";     file newfile = new file(file);           //environment.getexternalstoragedirectory().tostring()= /storage/emulated/0  string msgdata="p1000";         fileoutputstream outputstream;          try {             newfile.createnewfile();              outputstream = openfileoutput(file, context.mode_private);             outputstream.write(msgdata.getbytes());             outputstream.close();         } catch (exception e) {             e.tostring();             //e.printstacktrace();         } 

when open file /storage/emulated/0/documents/info.text, find empty while should have string "p1000";

why that? note: not have external storage (external sd card).

thanks.

do have write_external_storage permission in manifest?

try this: fileoutputstream outputstream = new fileoutputstream(file);


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -