OpenFileInput() gives nullpointer exception
<p>I am writing an <code>xml</code> file to the internal storage and read data from that. First time read is done properly but from the other Class if I read it, it gives me <code>nullPointer exception</code> so please tell me what is a problem? Thanks in advanced.</p>

<p>Write into file :</p>

<pre><code>FileOutputStream fos = openFileOutput("test.xml", Context.MODE_PRIVATE);
fos.write(string.getBytes());
fos.close();
</code></pre>

<p>Read from file:</p>

<pre><code>FileInputStream fis = getBaseContext().openFileInput("test.xml");
</code></pre>

<p>and Exception:</p>

<pre><code>12-13 16:45:09.929: W/System.err(630): java.lang.NullPointerException
12-13 16:45:09.939: W/System.err(630):  at android.view.View.performClick(View.java:2408)
12-13 16:45:09.949: W/System.err(630):  at android.view.View$PerformClick.run(View.java:8816)
12-13 16:45:09.949: W/System.err(630):  at android.os.Handler.handleCallback(Handler.java:587
12-13 16:45:09.949: W/System.err(630):  at android.os.Handler.dispatchMessage(Handler.java:92)
12-13 16:45:09.949: W/System.err(630):  at android.os.Looper.loop(Looper.java:123)
12-13 16:45:09.959: W/System.err(630):  at android.app.ActivityThread.main(ActivityThread.java:4627)
12-13 16:45:09.959: W/System.err(630):  at java.lang.reflect.Method.invokeNative(Native Method)
12-13 16:45:09.959: W/System.err(630):  at java.lang.reflect.Method.invoke(Method.java:521)
12-13 16:45:09.969: W/System.err(630):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
12-13 16:45:09.969: W/System.err(630):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
12-13 16:45:09.969: W/System.err(630):  at dalvik.system.NativeStart.main(Native Method)
</code></pre>
