ProblematicClass should not extend Activity. On Fri, May 27, 2011 at 9:10 AM, Marco <[email protected]> wrote: > Thanks for the very fast response. > >> The only reason I can think of for getFilesDir() to >> return null is if it's not a real live Activity instance >> (you created it via new MyActivity() instead of starting >> it with startActivity(), you call getFilesDir() sometime >> after the activity is destroyed, etc.). > > Where do I have to call startActivity()? > > It's not unlikely that I make something conceptually wrong > in my application, since I'm new to android. > > This is what I did: > > /*********************************************/ > // MainActivity.java > public class MainActivity extends Activity { > > public MainActivity() { > } > > @Override > public void onCreate(Bundle savedInstanceState) { > // getFilesDir() works here > AnotherClass myA = new AnotherClassImpl(); > myA.start(); > } > } > > // AnotherClassImpl.java > public class AnotherClassImpl implements AnotherClass { > public AnotherClassImpl () { > ProblematicClass props = ProblematicClass.getProperties(); > } > > // ProblematicClass.java > public class ProblematicClass extends Activity { > private static ProblematicClass myProblematicClass = null; > public static ProblematicClass getProperties(){ > if(myProblematicClass == null) { > myProblematicClass = new ProblematicClass(); > } > return myProblematicClass; > } > > public MediaSenseProperties() { > // getFilesDir() failes here > } > } > /*********************************************/ > > I hope this illustrates my method. All this should take > place in the same activity. > > Marco > > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en >
-- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy _The Busy Coder's Guide to Android Development_ Version 3.6 Available! -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

