fileinputstream - Why the txt file did not create in Android? -


i developing in android , found sample code , read , write data txt file following code:

the following function writing data text file:

private static final string mesh_data_file_name = "test.txt";  public void save(activity activity) {         try {             int i;             context context = activity;             fileoutputstream fos = activity.openfileoutput(mesh_data_file_name, context.mode_private);              string str;             (i = 0; < 10; i++) {                 str += "##" + i;             }              fos.write(str.getbytes());             fos.write('\n');             fos.close();         } catch (exception e) {             log.e(tag, "savemeshinfo exception: " + e);         }     } 

the following code reading data text file:

public void read(activity activity) {          try {             fileinputstream fin = activity.openfileinput(mesh_data_file_name);             bufferedreader br = new bufferedreader(new inputstreamreader(fin));              log.i(tag, "from file [" + mesh_data_file_name + "]...");              // read information             string   text = br.readline();             string[] strs = text.split("##", 4 + floodmesh.iv_len + floodmesh.key_len);              fin.close();         } catch (exception e) {           }     } 

it can see data log when call read function , test.txt should exists.

but didn't found test.txt via file manager app on android phone.

  1. why didn't found test.txt file on android phone ?
  2. if test.txt not exists , why read function can read data ?
  3. how find test.txt file ?

you've created file in app directory (/data/data/your.package) , don't have access there via file manager. file exists why can read via method won't see it. test code on emulator - able see file

if want test better , don't want use emulator can save file on sdcard, have access there via file manager , able see it


Comments

Popular posts from this blog

How to provide Authorization & Authentication using Asp.net, C#? -

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

How to use Authorization & Authentication in Asp.net, C#? -