title: ListFragment and context
body: <p>I am working for the first time with ListFragments. I want to display data from a sqlite database. </p>
  
  <p>My problem: I can't retrieve the context. </p>
  
  <p>I have tried this.getActivity() in my class which extends ListFragment- but the context is null.</p>
  
  <p>Then I have tried to save the context of my first activity(the ui which is displayed after starting the app) of my application as a static variable. But is this the right context?</p>
  
  <pre><code>static Context context; 
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
          //Setting the context
          context = this; 
  
          setContentView(R.layout.main);
      }
  
      public static Context getContext() {
          return context;
      } 
  </code></pre>
  
  <p>When I query the database I don't get any exceptions but the cursor is always empty. I have looked into my sqlite database - I have three rows of data (so the cursor should not be empty). </p>
  
  <p>My code for querying the data from the database: </p>
  
  <pre><code>Cursor cursor = null;
          try{
              open();
              cursor = database.rawQuery("select _id, surname, prename, street, zipcode, telephone, email from "+Database.getMyDbTable()+";", null);
          }catch(Exception ex){
              Log.e(TAG, "Could not get list");
              CharSequence text = "Die Liste kann nicht erstellt werden!";
              Toast toast = Toast.makeText(context, text, duration);
              toast.show();
          }
          Log.d(TAG, "Cursor "+cursor); 
          close(); 
  </code></pre>
  
  <p>How do I get the right context?</p>