title: SQLite database in combination with fragments
body: <p>I'm changing my application from Activity's to Fragments, it's going great but I've one bug that won't let me open my database. Here's the error (from the logcat):</p>
  
  <pre><code>05-17 15:28:38.704  13025-13025/com.MJV.werktijden             E/AndroidRuntime: FATAL EXCEPTION: main
      java.lang.NullPointerException
      at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:224)
      at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:164)
      at com.MJV.werktijden.DBAdapter.open(DBAdapter.java:71)
      at com.MJV.werktijden.OverviewFragment.onActivityCreated(OverviewFragment.java:38)
      at android.app.Fragment.performActivityCreated(Fragment.java:1703)
      at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:903)
      at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1057)
      at android.app.BackStackRecord.run(BackStackRecord.java:682)
      at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1435)
      at android.app.FragmentManagerImpl$1.run(FragmentManager.java:441)
      at android.os.Handler.handleCallback(Handler.java:725)
      at android.os.Handler.dispatchMessage(Handler.java:92)
      at android.os.Looper.loop(Looper.java:137)
      at android.app.ActivityThread.main(ActivityThread.java:5041)
      at java.lang.reflect.Method.invokeNative(Native Method)
      at java.lang.reflect.Method.invoke(Method.java:511)
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
      at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  
  <p>I tried to solve it myself, but I couldn't find the problem. Just because this database did work when I used it with Activity's.
  I'm opening the database with this method:</p>
  
  <pre><code>    //---opens the database---
  public DBAdapter open() throws SQLException
  {
      db = DBHelper.getWritableDatabase();
      return this;
  }
  </code></pre>
  
  <p>And that method is being called from my Fragment:</p>
  
  <pre><code>private final DBAdapter db = new DBAdapter(getActivity());
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
                           Bundle savedInstanceState) {
      View rootView = inflater.inflate(R.layout.overview_layout, container, false);
      return rootView;
  }
  
  public void onActivityCreated (Bundle savedInstanceState){
      listView = (ListView) getView().findViewById(R.id.listView1);
      db.open();
  </code></pre>
  
  <p>Thanks for helping in advance.</p>