know please anyone why is my application crashing while i am `rotating screen` in this fragment ? When i had blank `fragments` it works perfect, but from when i fullfill my `fragment` with `listview`, it is crashing, but only when app loaded fullfill `fragment`.

Here is my Fragment

```
public class PoznamkaFragment extends Fragment {

private DatabaseOp mDbHelper;
String username;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) 
{
    View v = inflater.inflate(R.layout.poznamka_frag, container, false);

    ListView listview = (ListView) v.findViewById(R.id.listPoznamka);

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

    showUserSettings(); 
    Cursor notesCursor = mDbHelper.fetchAllNotes(username);

    final PoznamkyCursorAdapter adapter = new PoznamkyCursorAdapter(getActivity(), notesCursor);
    listview.setAdapter(adapter);

    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("_id"));

            Intent intent = new Intent(getActivity(),PoznamkaShower.class);
            intent.putExtra(PoznamkaShower.ODOSLI, odosli);

            startActivity(intent);
            //Toast.makeText(getActivity(), odosli, Toast.LENGTH_SHORT).show();

        }
    });

    /*for (notesCursor.moveToFirst(); !notesCursor.isAfterLast(); notesCursor.moveToNext()) 
    {
        // do what you need with the cursor here
        Log.d("Poznamky", notesCursor.getString(notesCursor.getColumnIndex("nazov")));
    }*/

    return v;
}

@Override
public void onResume() 
{
    super.onResume();

    ListView listview = (ListView) getActivity().findViewById(R.id.listPoznamka);

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

    Cursor notesCursor = mDbHelper.fetchAllNotes(username);
    final PoznamkyCursorAdapter adapter = new PoznamkyCursorAdapter(getActivity(), notesCursor);
    listview.setAdapter(adapter);
}

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

public static PoznamkaFragment newInstance() {

    PoznamkaFragment f = new PoznamkaFragment();
    return f;
}

private void showUserSettings() 
{
    SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity());

    username = sharedPrefs.getString("prefUsername", "NULL");
}

}

```

and here is MainActivity 

```
public class MainActivity extends FragmentActivity {

public static final String PREZIVKA = "prezivka";

MyPagerAdapter mMyPagerAdapter;

ViewPager mViewPager;

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

    Intent i = getIntent();
    String prezivka = getResources().getString(R.string.logged)+" "+i.getStringExtra(PREZIVKA);

    if (prezivka.length()>0)
        Toast.makeText (this, prezivka, Toast.LENGTH_SHORT).show();

    mMyPagerAdapter = new MyPagerAdapter(
            getSupportFragmentManager());

    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mMyPagerAdapter);

}

@Override
public void onResume ()
{
    super.onResume();

    mMyPagerAdapter = new MyPagerAdapter(
            getSupportFragmentManager());

    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mMyPagerAdapter);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) 
{
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}

/**
 * A {@link FragmentPagerAdapter} that returns a fragment corresponding to
 * one of the sections/tabs/pages.
 */
public class MyPagerAdapter extends FragmentPagerAdapter {

    public MyPagerAdapter(FragmentManager fm) {
        super(fm);
    }

    @Override
    public Fragment getItem(int position) {

        switch(position){
             case 0:
                 return UlohaFragment.newInstance();
             case 1:
                 return PredmetFragment.newInstance();
             case 2:
                 return PoznamkaFragment.newInstance();
             case 3:
                 return SviatokFragment.newInstance();
             default: 
                 return UlohaFragment.newInstance();
        }
    }

    @Override
    public int getCount() {
        // Show 4 total pages.
        return 4;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        Locale l = Locale.getDefault();
        switch (position) {
        case 0:
            return getString(R.string.title_section1).toUpperCase(l);
        case 1:
            return getString(R.string.title_section2).toUpperCase(l);
        case 2:
            return getString(R.string.title_section3).toUpperCase(l);
        case 3:
            return getString(R.string.title_section4).toUpperCase(l);
        }
        return null;
    }
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle presses on the action bar items
    switch (item.getItemId()) {
        case R.id.action_pridat:
            openPridaj();
            return true;
        case R.id.action_hladat:
            openHladaj();
            return true;
        case R.id.action_settings:
            openSettings();
            return true;
        case R.id.action_app:
            openApp();
            return true;
        default:
            return super.onOptionsItemSelected(item);
    }
}

public void openPridaj()
{
    Intent intent = new Intent(this, PridajActivity.class);
    startActivity(intent);  
}

public void openHladaj()
{
    Intent intent = new Intent(this, HladajActivity.class);
    startActivity(intent);  
}

public void openSettings()
{
    Intent intent = new Intent(this, NastaveniaActivity.class);
    startActivity(intent);  
}

public void openApp()
{
    Intent intent = new Intent(this, AppActivity.class);
    startActivity(intent);
}
}

```

Here is LogCat

```
04-12 12:55:09.190: E/AndroidRuntime(8569): FATAL EXCEPTION: main
04-12 12:55:09.190: E/AndroidRuntime(8569): java.lang.RuntimeException: Unable to resume activity {sk.tomino.login/sk.tomino.login.MainActivity}: java.lang.NullPointerException
04-12 12:55:09.190: E/AndroidRuntime(8569):     at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3052)
04-12 12:55:09.190: E/AndroidRuntime(8569):     at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3093)
04-12 12:55:09.190: E/AndroidRuntime(8569):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2396)
04-12 12:55:09.190: E/AndroidRuntime(8569):     at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:4086)
04-12 12:55:09.190: E/AndroidRuntime(8569):     at android.app.ActivityThread.access$700(ActivityThread.java:151)
04-12 12:55:09.190: E/AndroidRuntime(8569):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1341)
04-12 12:55:09.190: E/AndroidRuntime(8569):     at android.os.Handler.dispatchMessage(Handler.java:99)
04-12 12:55:09.190: E/AndroidRuntime(8569):     at android.os.Looper.loop(Looper.java:155)
04-12 12:55:09.190: E/AndroidRuntime(8569):     at android.app.ActivityThread.main(ActivityThread.java:5520)
04-12 12:55:09.190: E/AndroidRuntime(8569):     at java.lang.reflect.Method.invokeNative(Native Method)
04-12 12:55:09.190: E/AndroidRuntime(8569):     at java.lang.reflect.Method.invoke(Method.java:511)
04-12 12:55:09.190: E/AndroidRuntime(8569):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1029)
04-12 12:55:09.190: E/AndroidRuntime(8569):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:796)
04-12 12:55:09.190: E/AndroidRuntime(8569):     at dalvik.system.NativeStart.main(Native Method)
04-12 12:55:09.190: E/AndroidRuntime(8569): Caused by: java.lang.NullPointerException
04-12 12:55:09.190: E/AndroidRuntime(8569):     at sk.tomino.login.PoznamkaFragment.onResume(PoznamkaFragment.java:80)
04-12 12:55:09.190: E/AndroidRuntime(8569):     at android.support.v4.app.Fragment.performResume(Fragment.java:1543)
04-12 12:55:09.190: E/AndroidRuntime(8569):     at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:963)
04-12 12:55:09.190: E/AndroidRuntime(8569):     at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1104)
04-12 12:55:09.190: E/AndroidRuntime(8569):     at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1086)
04-12 12:55:09.190: E/AndroidRuntime(8569):     at android.support.v4.app.FragmentManagerImpl.dispatchResume(FragmentManager.java:1894)
04-12 12:55:09.190: E/AndroidRuntime(8569):     at android.support.v4.app.FragmentActivity.onResumeFragments(FragmentActivity.java:466)
04-12 12:55:09.190: E/AndroidRuntime(8569):     at android.support.v4.app.FragmentActivity.onPostResume(FragmentActivity.java:455)
04-12 12:55:09.190: E/AndroidRuntime(8569):     at android.app.Activity.performResume(Activity.java:5161)
04-12 12:55:09.190: E/AndroidRuntime(8569):     at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3035)
04-12 12:55:09.190: E/AndroidRuntime(8569):     ... 13 more

```