Null cursor on Listview
<p>I'm trying to follow along with a book and i missed something in this tutorial. However i lost my way somewhere and i'm Trying to figure out why this crashes with a null pointer exception. Can only one see what i'm missing here?</p>

<pre><code>public class HistoryFragment extends Fragment {

    DbHelper dbHelper;
    SQLiteDatabase db;
    Cursor cursor;
    ListView listTimeline;
    SimpleCursorAdapter adapter;
    static final String[] FROM = {DbHelper.KEY_CHARTING_DATE, DbHelper.KEY_NAME, DbHelper.KEY_CHARTING_NOTES};
    static final int[] TO = {R.id.textDate, R.id.textUser, R.id.textText}; 



    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState); 
    }       

     @Override
     public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

        View view = inflater.inflate(R.layout.fragment_history, container, false);

        listTimeline = (ListView) getView().findViewById(R.id.listTimeline);

        //connect to database
        dbHelper = new DbHelper(getActivity());
        db = dbHelper.getReadableDatabase();

        return view;

     }

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

         //close datbase
         db.close();
     }

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

         //Get the data from the database
         cursor = db.query(DbHelper.DATABASE_TABLE, null, null, null, null, null, DbHelper.KEY_CHARTING_DATE + " DESC");
         getActivity().startManagingCursor(cursor);

         //Sup up the adapter
         adapter.setViewBinder(VIEW_BINDER);
         listTimeline.setAdapter(adapter);
    }

     static final ViewBinder VIEW_BINDER = new ViewBinder() {
         public boolean setViewValue(View view, Cursor cursor, int columnIndex) {
             if (view.getId() != R.id.textDate)
                 return false;

             //update the created at text
             long timestamp = cursor.getLong(columnIndex);
             CharSequence relTime = DateUtils.getRelativeTimeSpanString(view.getContext(), timestamp);
             ((TextView) view).setText(relTime);

             return true;
         }
     };
}
</code></pre>

<p>Logcat:</p>

<pre><code>        05-15 20:37:49.412: E/AndroidRuntime(945): java.lang.NullPointerException
        05-15 20:37:49.412: E/AndroidRuntime(945):  at com.projectcaruso.naturalfamilyplaning.HistoryFragment.onCreateView(HistoryFragment.java:41)
        05-15 20:37:49.412: E/AndroidRuntime(945):  at android.support.v4.app.Fragment.performCreateView(Fragment.java:1460)
        05-15 20:37:49.412: E/AndroidRuntime(945):  at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:911)
        05-15 20:37:49.412: E/AndroidRuntime(945):  at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1088)
        05-15 20:37:49.412: E/AndroidRuntime(945):  at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682)
        05-15 20:37:49.412: E/AndroidRuntime(945):  at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1444)
        05-15 20:37:49.412: E/AndroidRuntime(945):  at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:429)
        05-15 20:37:49.412: E/AndroidRuntime(945):  at android.os.Handler.handleCallback(Handler.java:725)
        05-15 20:37:49.412: E/AndroidRuntime(945):  at android.os.Handler.dispatchMessage(Handler.java:92)
        05-15 20:37:49.412: E/AndroidRuntime(945):  at android.os.Looper.loop(Looper.java:137)
        05-15 20:37:49.412: E/AndroidRuntime(945):  at android.app.ActivityThread.main(ActivityThread.java:5041)
        05-15 20:37:49.412: E/AndroidRuntime(945):  at java.lang.reflect.Method.invokeNative(Native Method)
        05-15 20:37:49.412: E/AndroidRuntime(945):  at java.lang.reflect.Method.invoke(Method.java:511)
        05-15 20:37:49.412: E/AndroidRuntime(945):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
        05-15 20:37:49.412: E/AndroidRuntime(945):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
        05-15 20:37:49.412: E/AndroidRuntime(945):  at dalvik.system.NativeStart.main(Native Method)
</code></pre>
