コード例 #1
0
 /**
  * If you are _not_ using the {@link OrmLiteBaseActivity} type classes then you will need to call
  * this in a static method in your code.
  */
 public static synchronized void setOpenHelperClass(
     Class<? extends OrmLiteSqliteOpenHelper> openHelperClass) {
   if (openHelperClass == null) {
     helperClass = null;
   } else {
     innerSetHelperClass(openHelperClass);
   }
 }
コード例 #2
0
 /**
  * Similar to {@link #getHelper(Context, Class)} (which is recommended) except we have to find the
  * helper class through other means. This method requires that the Context be a class that extends
  * one of ORMLite's Android base classes such as {@link OrmLiteBaseActivity}. Either that or the
  * helper class needs to be set in the strings.xml.
  *
  * <p>To find the helper class, this does the following: <br>
  * 1) If the class has been set with a call to {@link #setOpenHelperClass(Class)}, it will be used
  * to construct a helper. <br>
  * 2) If the resource class name is configured in the strings.xml file it will be used. <br>
  * 3) The context class hierarchy is walked looking at the generic parameters for a class
  * extending OrmLiteSqliteOpenHelper. This is used by the {@link OrmLiteBaseActivity} and other
  * base classes. <br>
  * 4) An exception is thrown saying that it was not able to set the helper class.
  *
  * @deprecated Should use {@link #getHelper(Context, Class)}
  */
 @Deprecated
 public static synchronized OrmLiteSqliteOpenHelper getHelper(Context context) {
   if (helperClass == null) {
     if (context == null) {
       throw new IllegalArgumentException("context argument is null");
     }
     Context appContext = context.getApplicationContext();
     innerSetHelperClass(lookupHelperClass(appContext, context.getClass()));
   }
   return loadHelper(context, helperClass);
 }
コード例 #3
0
 /**
  * Create a static instance of our open helper from the helper class. This has a usage counter on
  * it so make sure all calls to this method have an associated call to {@link #releaseHelper()}.
  * This should be called during an onCreate() type of method when the application or service is
  * starting. The caller should then keep the helper around until it is shutting down when {@link
  * #releaseHelper()} should be called.
  */
 public static synchronized <T extends OrmLiteSqliteOpenHelper> T getHelper(
     Context context, Class<T> openHelperClass) {
   innerSetHelperClass(openHelperClass);
   return loadHelper(context, openHelperClass);
 }