Crash on Calling getFilesDir()
<p>Crash on calling getFilesDir() , Here is the code</p>

<pre><code>public void generateFile() throws IOException{


    File fileDir = getFilesDir(); //crashing

    String filedir=fileDir.toString();

    String OUTPUT_FILE = "123.txt";
    String data = "TEST DATA to WRITE";

    File newFile = new File(fileDir,OUTPUT_FILE);

    ........
</code></pre>

<p>and stacktrace</p>

<pre><code>03-24 16:33:33.623: VERBOSE/APP(2180): Calling GenerateFile
03-24 16:33:33.623: DEBUG/AndroidRuntime(2180): Shutting down VM
03-24 16:33:33.623: WARN/dalvikvm(2180): threadid=1: thread exiting with uncaught exception (group=0x4001d8a8)
03-24 16:33:33.670: ERROR/AndroidRuntime(2180): FATAL EXCEPTION: main
03-24 16:33:33.670: ERROR/AndroidRuntime(2180): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.Android.APP/com.Android.APP.Readings}: java.lang.NullPointerException
03-24 16:33:33.670: ERROR/AndroidRuntime(2180):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
03-24 16:33:33.670: ERROR/AndroidRuntime(2180):     at android.app.ActivityThread.startActivityNow(ActivityThread.java:2503)
03-24 16:33:33.670: ERROR/AndroidRuntime(2180):     at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:127)
03-24 16:33:33.670: ERROR/AndroidRuntime(2180):     at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:339)
03-24 16:33:33.670: ERROR/AndroidRuntime(2180):     at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:654)
03-24 16:33:33.670: ERROR/AndroidRuntime(2180):     at android.widget.TabHost.setCurrentTab(TabHost.java:326)
03-24 16:33:33.670: ERROR/AndroidRuntime(2180):     at android.widget.TabHost$2.onTabSelectionChanged(TabHost.java:132)
03-24 16:33:33.670: ERROR/AndroidRuntime(2180):     at android.widget.TabWidget$TabClickListener.onClick(TabWidget.java:456)
03-24 16:33:33.670: ERROR/AndroidRuntime(2180):     at android.view.View.performClick(View.java:2408)
03-24 16:33:33.670: ERROR/AndroidRuntime(2180):     at android.view.View$PerformClick.run(View.java:8818)
03-24 16:33:33.670: ERROR/AndroidRuntime(2180):     at android.os.Handler.handleCallback(Handler.java:587)
03-24 16:33:33.670: ERROR/AndroidRuntime(2180):     at android.os.Handler.dispatchMessage(Handler.java:92)
03-24 16:33:33.670: ERROR/AndroidRuntime(2180):     at android.os.Looper.loop(Looper.java:123)
03-24 16:33:33.670: ERROR/AndroidRuntime(2180):     at android.app.ActivityThread.main(ActivityThread.java:4627)
03-24 16:33:33.670: ERROR/AndroidRuntime(2180):     at java.lang.reflect.Method.invokeNative(Native Method)
03-24 16:33:33.670: ERROR/AndroidRuntime(2180):     at java.lang.reflect.Method.invoke(Method.java:521)
03-24 16:33:33.670: ERROR/AndroidRuntime(2180):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
03-24 16:33:33.670: ERROR/AndroidRuntime(2180):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
03-24 16:33:33.670: ERROR/AndroidRuntime(2180):     at dalvik.system.NativeStart.main(Native Method)
03-24 16:33:33.670: ERROR/AndroidRuntime(2180): Caused by: java.lang.NullPointerException
03-24 16:33:33.670: ERROR/AndroidRuntime(2180):     at android.content.ContextWrapper.getFilesDir(ContextWrapper.java:178)
03-24 16:33:33.670: ERROR/AndroidRuntime(2180):     at com.Android.APP.Logging.generateFile(Logging.java:33)
03-24 16:33:33.670: ERROR/AndroidRuntime(2180):     at com.Android.APP.Readings.onCreate(Readings.java:90)
03-24 16:33:33.670: ERROR/AndroidRuntime(2180):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-24 16:33:33.670: ERROR/AndroidRuntime(2180):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
03-24 16:33:33.670: ERROR/AndroidRuntime(2180):     ... 18 more
</code></pre>
