Android creating file on internal storage -


i trying create .txt file in android, have tested lot of options how achieve this, think file created can't find it, should writed somehow public in public directory can access it.

example:

cachefile = new java.io.file(getfilesdir(), "cache.txt");         if(cachefile.exists() && !cachefile.isdirectory()) {             try {                 writer = new filewriter(cachefile);                 bufferedreader br = new bufferedreader(new filereader(cachefile));                 string tempo;                 while((tempo = br.readline()) != null){                     log.i("test","reading cache "+tempo);                     if (tempo.contains("http")) {                         musicurl.add(tempo);                     }                     else {                         mydatalist.add(tempo);                     }                 }             } catch (ioexception e) {                 e.printstacktrace();             }          }         else {             try {                 log.i("test", "creating cache ? " + cachefile.createnewfile() + " in " + getfilesdir());                 writer = new filewriter(cachefile);             } catch (ioexception e) {                 e.printstacktrace();             }         } 

what other option i've tried: android file on internal storage not found

you should use 1 of following:

getexternalfilesdir() getexternalstoargedir() 

the first create file in /sdcard/android/app.package/file
second root of /sdcard/

the call make, getfilesdir(), returning path in /data/data/app.package/file not accessable other application.


Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -

Nuget pack csproj using nuspec -