title: Using Green DAO with content provider get error
body: <p>I use GreenDao to generate ContentProvider and when I trying to use it went wrong.it tell me "DaoSession must be set during content provider is active".I dont know where to set the DaoSession.</p>
  
  <p><strong>ContentProvider class as follows</strong></p>
  
  <pre><code>public class ContactContentProvider extends ContentProvider {
  
  public static final String AUTHORITY         = "com.junsucc.www.provider";
  public static final String BASE_PATH         = "contact";
  public static final Uri    CONTENT_URI       = Uri.parse("content://" + AUTHORITY + "/" + BASE_PATH);
  public static final String CONTENT_TYPE      = ContentResolver.CURSOR_DIR_BASE_TYPE
          + "/" + BASE_PATH;
  public static final String CONTENT_ITEM_TYPE = ContentResolver.CURSOR_ITEM_BASE_TYPE
          + "/" + BASE_PATH;
  
  private static final String TABLENAME = ContactDao.TABLENAME;
  private static final String PK        = ContactDao.Properties.Id
          .columnName;
  
  private static final int CONTACT_DIR = 0;
  private static final int CONTACT_ID  = 1;
  
  private static final UriMatcher sURIMatcher;
  static {
      sURIMatcher = new UriMatcher(UriMatcher.NO_MATCH);
      sURIMatcher.addURI(AUTHORITY, BASE_PATH, CONTACT_DIR);
      sURIMatcher.addURI(AUTHORITY, BASE_PATH + "/#", CONTACT_ID);
  }
  
  public  DaoSession daoSession=BaseApplication.getDaoSession();
  
  
  @Override
  public boolean onCreate() {
      // if(daoSession == null) {
      // throw new IllegalStateException("DaoSession must be set before content provider is created");
      // }
      DaoLog.d("Content Provider started: " + CONTENT_URI);
      return true;
  }
  
  protected SQLiteDatabase getDatabase() {
  
      if (daoSession == null) {
          throw new IllegalStateException("DaoSession must be set during content provider is active");
      }
      return daoSession.getDatabase();
  }
  
      ......
  </code></pre>
  
  <p><strong>the error as follow</strong></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>java.lang.IllegalStateException: DaoSession must be set during content provider is active
  at com.junsucc.www.ContactContentProvider.getDatabase(ContactContentProvider.java:71)
  at com.junsucc.www.ContactContentProvider.insert(ContactContentProvider.java:83)
  at android.content.ContentProvider$Transport.insert(ContentProvider.java:220)
  at android.content.ContentResolver.insert(ContentResolver.java:1190)
  at com.junsucc.junsucc.MD5UtilsTest.testProvider(MD5UtilsTest.java:58)
  at java.lang.reflect.Method.invokeNative(Native Method)
  at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:191)
  at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:176)
  at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:554)
  at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1701)</code></pre>
  </div>
  </div>
  </p>
  
  <p>but I had setted th DaoSession inside my Application</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>public class BaseApplication extends Application {
  
      private static Context    mContext;
  
      private static DaoMaster  mDaoMaster;
      private static DaoSession mDaoSession;
  
      public static DaoMaster getDaoMaster() {
          return mDaoMaster;
      }
  
      public static Context getContext() {
          return mContext;
      }
  
      @Override
      public void onCreate() {
  
          mContext = getApplicationContext();
          DaoMaster.OpenHelper helper = new DaoMaster.DevOpenHelper(mContext, Constants.DB_NAME, null);
          mDaoMaster = new DaoMaster(helper.getWritableDatabase());
          mDaoSession = mDaoMaster.newSession();
          super.onCreate();
      }
  
  }</code></pre>
  </div>
  </div>
  </p>