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)