I understand that Android uses an applicaiton ID for File I/O when
using openFileInput and openFileOutput.

My question is if I create an instance of a class in the Activity
onCreate like the following and do some file IO from the new class,
why does it fail? If I make the MyClass an inner class of the Activity
class this works, so it has to be a context issue. Is there any way to
pass the activity context to the MyClass methods so the openFileInput
and openFileOutput work in the newly created objMyClass object?

public void onCreate(Bundle icicle)
{
     MyClass objMyClass = new MyClass();
     objMyClass.DoFileIO();
}


public class MyClass extends Activity
{
     public void DoFileIO()
     {
          objFileInputStream = openFileInput("SomeFileName");  <--
NullPointerException

          objInputStreamReader = new InputStreamReader
(objFileInputStream);
          objBufferedReader = new BufferedReader
(objInputStreamReader);
     }
}


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to