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
Post a Comment