android - getFilesDir() returning null -


getfilesdir() returning null, bizarre. what's worse, code is...painfully simple:

public class main extends activity { /** called when activity first created. */ @override public void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.main);      file f = this.getfilesdir();     f.getabsolutepath();      tempclicked((togglebutton)findviewbyid(r.id.temptoggle)); } 

this crash on f.getabsolutepath(). it's running in emulator emulating 2.3.3 system @ 1024x600.

google returns nothing on this...so why on earth happening? , how fix it?!

thanks lot!

edit:: solved!

well, somewhat...

i think turned out emulator error. changed skin of emulator wxvga, , allowed write files correctly. , when changed resolution 1024x600 kept working correctly.

so, if has similar error, suggest play around emulator until find way past bug.

try adding before f.getabsolutepath():

file f = new file(this.getapplicationcontext().getfilesdir() + "/"); f.mkdirs(); 

Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -