Android InstrumentationTestCase getFilesDir() returns null
<p>I am using <code>InstrumentationTestCase</code> to unit test a component of my application.</p>

<p>The component persists data to the internal storage and uses <code>Context::fileList();</code> to retrieve the persisted files.</p>

<p>I experience the following problem: Using this method in the app (on the device) works perfectly fine. But when I try to (Android-)Unit-Test (also on the Device) with use of <code>InstrumentationTestCase</code> I get a <code>NullPointerException</code> inside the <code>fileList()</code> method. I digged into the android source and found out that <code>getFilesDir()</code> <a href="http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/4.1.1_r1/android/app/ContextImpl.java#ContextImpl.getFilesDir%28%29" rel="nofollow">(see source here)</a> returns null and causes this error.</p>

<p>The code to reproduce is the following:</p>

<pre><code>public class MyTestCase extends InstrumentationTestCase
{   
    public void testExample() throws Exception
    {
        assertNotNull(getInstrumentation().getContext().getFilesDir()); // Fails
    }
}
</code></pre>

<p>My questions are: Is this behaviour intended? What can I do to circumvent this issue? Am I using <code>InstrumentationTestCase</code> right or should I use something different?</p>

<p>I found <a href="http://stackoverflow.com/questions/13796529/android-provider-test-case-2-and-getfilesdir">this question</a> but I'm not sure if this covers the same problem I have.</p>
