Esempio n. 1
0
 private static synchronized KJDB getInstance(DaoConfig daoConfig) {
   KJDB dao = daoMap.get(daoConfig.getDbName());
   if (dao == null) {
     dao = new KJDB(daoConfig);
     daoMap.put(daoConfig.getDbName(), dao);
   }
   return dao;
 }
Esempio n. 2
0
 private KJDB(DaoConfig config) {
   if (config == null) {
     throw new RuntimeException("daoConfig is null");
   }
   if (config.getContext() == null) {
     throw new RuntimeException("android context is null");
   }
   if (config.getTargetDirectory() != null && config.getTargetDirectory().trim().length() > 0) {
     this.db = createDbFileOnSDCard(config.getTargetDirectory(), config.getDbName());
   } else {
     this.db =
         new SqliteDbHelper(
                 config.getContext().getApplicationContext(),
                 config.getDbName(),
                 config.getDbVersion(),
                 config.getDbUpdateListener())
             .getWritableDatabase();
   }
   this.config = config;
 }