Android static vs nonstatic issue
<p>I've been trying to call the following:</p>

<pre><code>public static void startfile() {
    Log.i("File Works", "working2 ");

    try {
        FileOutputStream fos = openFileOutput("sdcard/sdtext.txt", MODE_WORLD_WRITEABLE);
    } catch (FileNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
</code></pre>

<p>I get an error that tells me that "Cannot make a static reference to the non-static method openFileOutput(String, int) from the type ContextWrapper"</p>

<p>So I searched for that error and found <a href="http://helpdesk.objects.com.au/java/how-to-fix-cannot-make-a-static-reference-to-the-non-static-method" rel="nofollow">this site</a>.</p>

<p>I implemented this:</p>

<pre><code>public static void startfile(Trackfile O) {
    Log.i("File Works", "working2 ");
    O.nonstatstartfile();
}

public void nonstatstartfile(){
    Log.i("File Works", "nonStat");
    try {
        FileOutputStream fos = openFileOutput("sdcard/sdtext.txt", MODE_WORLD_WRITEABLE);
    } catch (FileNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } 
}
</code></pre>

<p>When I call startfile from another class getting a Null pointer error.  What argument do I need to send to avoid the null pointer error?</p>
