Question: I have written a simple code

```
if (context != null) 
    {
        File mydir = context.getDir("abc",0);
    }

```

As per my understanding, i can pass any random string as the first parameter.
This will be name of the directory created. 
Also this code is already inside null check, so context cannot be null.

but this is giving NullPointerException

```
11-10 09:43:44.839: E/AndroidRuntime(11441): FATAL EXCEPTION: DOWNLOAD_THREAD
11-10 09:43:44.839: E/AndroidRuntime(11441): Process: com.samsung.samsunggearapps, PID: 11441
11-10 09:43:44.839: E/AndroidRuntime(11441): java.lang.NullPointerException
11-10 09:43:44.839: E/AndroidRuntime(11441):    at android.content.ContextWrapper.getDir(ContextWrapper.java:257)

```

EDIT: I tried using getApplicationContext(); . Even that is null.

```
11-10 11:31:17.919: E/AndroidRuntime(21038): java.lang.NullPointerException
11-10 11:31:17.919: E/AndroidRuntime(21038):    at android.content.ContextWrapper.getApplicationContext(ContextWrapper.java:114)

```

Answer: 
I think you cant do that. You must specify `where` (1st param) and `how` (2nd param):

```
File mydir = context.getDir(Environment.DIRECTORY_PICTURES, Context.MODE_PRIVATE);

```
getDir() enables you to create any file or directory in the internal memory, which is also accessible by other applications depending on the mode you create.

```
File dir = ctx.getDir("abc", Context.MODE_PRIVATE);

```