Why is my `ListView` adapter writing me a `NullPointerException`? In other fragmetns/activities is all ok, only in this class its not working. 

I dont figure out why ... I insert some datas first and in this class I can show them. Yes inserting method is after setting adapter, but it will may go

**SviatokPridajActivity.java** 

```
public class SviatokPridajActivity extends Activity 
{   
private DatabaseOp mDbHelper;
ListView listview;
String username;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.sviatok_pridaj);

    this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

    listview = (ListView) findViewById(R.id.listSviatok);

    showUserSettings(); 

    mDbHelper = new DatabaseOp(this);
    mDbHelper.open();

    Cursor sviatokCursor = mDbHelper.fetchAllSviatokNastav(username, 3);

    final SviatokCursorAdapter adapter = new SviatokCursorAdapter(this, sviatokCursor);
    listview.setAdapter(adapter);

    if (listview.getCount()==0)
    {
        mDbHelper.naplnSviatky(username);
    }

    listview.setOnItemClickListener(new OnItemClickListener() 
    {
        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int stlpec, long arg3) 
        {
            // TODO Auto-generated method stub
            Cursor cur = (Cursor) adapter.getItem(stlpec);
            String odosli = cur.getString(cur.getColumnIndex("nazov"));

            //adapter.notifyDataSetChanged();               
        }
    });
}

@Override
public void onPause() 
{
    super.onPause();
    mDbHelper.close();
}

private void showUserSettings() 
{
    SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
    username = sharedPrefs.getString("prefUsername", "NULL");
}
}

```

**Logcat**

```
04-15 16:40:14.141: E/AndroidRuntime(19326): FATAL EXCEPTION: main
04-15 16:40:14.141: E/AndroidRuntime(19326): java.lang.RuntimeException: Unable to start activity ComponentInfo{sk.tomino.studentDiary/sk.tomino.studentDiary.SviatokPridajActivity}: java.lang.NullPointerException
04-15 16:40:14.141: E/AndroidRuntime(19326):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2355)
04-15 16:40:14.141: E/AndroidRuntime(19326):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2391)
04-15 16:40:14.141: E/AndroidRuntime(19326):    at android.app.ActivityThread.access$600(ActivityThread.java:151)
04-15 16:40:14.141: E/AndroidRuntime(19326):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1335)
04-15 16:40:14.141: E/AndroidRuntime(19326):    at android.os.Handler.dispatchMessage(Handler.java:99)
04-15 16:40:14.141: E/AndroidRuntime(19326):    at android.os.Looper.loop(Looper.java:155)
04-15 16:40:14.141: E/AndroidRuntime(19326):    at android.app.ActivityThread.main(ActivityThread.java:5520)
04-15 16:40:14.141: E/AndroidRuntime(19326):    at java.lang.reflect.Method.invokeNative(Native Method)
04-15 16:40:14.141: E/AndroidRuntime(19326):    at java.lang.reflect.Method.invoke(Method.java:511)
04-15 16:40:14.141: E/AndroidRuntime(19326):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1029)
04-15 16:40:14.141: E/AndroidRuntime(19326):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:796)
04-15 16:40:14.141: E/AndroidRuntime(19326):    at dalvik.system.NativeStart.main(Native Method)
04-15 16:40:14.141: E/AndroidRuntime(19326): Caused by: java.lang.NullPointerException
04-15 16:40:14.141: E/AndroidRuntime(19326):    at sk.tomino.studentDiary.SviatokPridajActivity.onCreate(SviatokPridajActivity.java:38)
04-15 16:40:14.141: E/AndroidRuntime(19326):    at android.app.Activity.performCreate(Activity.java:5066)
04-15 16:40:14.141: E/AndroidRuntime(19326):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1101)
04-15 16:40:14.141: E/AndroidRuntime(19326):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2311)
04-15 16:40:14.141: E/AndroidRuntime(19326):    ... 11 more

```