Java Code Examples for com.activeandroid.ActiveAndroid#initialize()

The following examples show how to use com.activeandroid.ActiveAndroid#initialize() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ContentProvider.java    From mobile-android-survey-app with MIT License 6 votes vote down vote up
@Override
public boolean onCreate() {
	ActiveAndroid.initialize(getConfiguration());
	sAuthority = getAuthority();

	final List<TableInfo> tableInfos = new ArrayList<TableInfo>(Cache.getTableInfos());
	final int size = tableInfos.size();
	for (int i = 0; i < size; i++) {
		final TableInfo tableInfo = tableInfos.get(i);
		final int tableKey = (i * 2) + 1;
		final int itemKey = (i * 2) + 2;

		// content://<authority>/<table>
		URI_MATCHER.addURI(sAuthority, tableInfo.getTableName().toLowerCase(), tableKey);
		TYPE_CODES.put(tableKey, tableInfo.getType());

		// content://<authority>/<table>/<id>
		URI_MATCHER.addURI(sAuthority, tableInfo.getTableName().toLowerCase() + "/#", itemKey);
		TYPE_CODES.put(itemKey, tableInfo.getType());
	}

	return true;
}
 
Example 2
Source File: xdrip.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onCreate() {
    xdrip.context = getApplicationContext();
    super.onCreate();
    try {
        if (PreferenceManager.getDefaultSharedPreferences(xdrip.context).getBoolean("enable_crashlytics", true)) {
            initCrashlytics(this);
        }
    } catch (Exception e) {
        Log.e(TAG, e.toString());
    }
    PreferenceManager.setDefaultValues(this, R.xml.preferences, true);
    ActiveAndroid.initialize(this);
    updateMigrations();
    DemiGod.isPresent();
    JoH.forceBatteryWhitelisting();
    executor = new PlusAsyncExecutor();
    VersionTracker.updateDevice();
    disableUpdates();
}
 
Example 3
Source File: ContentProvider.java    From clear-todolist with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean onCreate() {
	ActiveAndroid.initialize(getConfiguration());
	sAuthority = getAuthority();

	final List<TableInfo> tableInfos = new ArrayList<TableInfo>(Cache.getTableInfos());
	final int size = tableInfos.size();
	for (int i = 0; i < size; i++) {
		final TableInfo tableInfo = tableInfos.get(i);
		final int tableKey = (i * 2) + 1;
		final int itemKey = (i * 2) + 2;

		// content://<authority>/<table>
		URI_MATCHER.addURI(sAuthority, tableInfo.getTableName().toLowerCase(), tableKey);
		TYPE_CODES.put(tableKey, tableInfo.getType());

		// content://<authority>/<table>/<id>
		URI_MATCHER.addURI(sAuthority, tableInfo.getTableName().toLowerCase() + "/#", itemKey);
		TYPE_CODES.put(itemKey, tableInfo.getType());
	}

	return true;
}
 
Example 4
Source File: Sensor.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
public static void InitDb(Context context) {//KS
    Configuration dbConfiguration = new Configuration.Builder(context).create();
    try {
        SQLiteDatabase db = Cache.openDatabase();
        if (db != null) {
            Log.d("wearSENSOR", "InitDb DB exists");
        }
        else {
            ActiveAndroid.initialize(dbConfiguration);
            Log.d("wearSENSOR", "InitDb DB does NOT exist. Call ActiveAndroid.initialize()");
        }
    } catch (Exception e) {
        ActiveAndroid.initialize(dbConfiguration);
        Log.d("wearSENSOR", "InitDb CATCH: DB does NOT exist. Call ActiveAndroid.initialize()");
    }
}
 
Example 5
Source File: xdrip.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onCreate() {
    xdrip.context = getApplicationContext();
    super.onCreate();
    try {
        if (PreferenceManager.getDefaultSharedPreferences(xdrip.context).getBoolean("enable_crashlytics", true)) {
            initCrashlytics(this);
        }
    } catch (Exception e) {
        Log.e(TAG, e.toString());
    }
    PreferenceManager.setDefaultValues(this, R.xml.preferences, true);
    ActiveAndroid.initialize(this);
    updateMigrations();
    DemiGod.isPresent();
    JoH.forceBatteryWhitelisting();
    executor = new PlusAsyncExecutor();
    VersionTracker.updateDevice();
    disableUpdates();
}
 
Example 6
Source File: MainApplication.java    From AndroidDatabaseLibraryComparison with MIT License 6 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();

    ActiveAndroid.initialize(new Configuration.Builder(this)
                                     .setDatabaseName("activeandroid")
                                     .setDatabaseVersion(1)
                                     .setModelClasses(SimpleAddressItem.class, AddressItem.class,
                                                      AddressBook.class, Contact.class).create());

    Ollie.with(this)
            .setName("ollie")
            .setVersion(1)
            .setLogLevel(Ollie.LogLevel.FULL)
            .init();

    FlowManager.init(this);

    Sprinkles.init(this, "sprinkles.db", 2);

    RealmConfiguration realmConfig = new RealmConfiguration.Builder(this).build();
    Realm.setDefaultConfiguration(realmConfig);

    mDatabase = getDatabase();
}
 
Example 7
Source File: InsertTest.java    From AirData with MIT License 5 votes vote down vote up
public void testActiveAndroidSelect(){
        ActiveAndroid.initialize(getContext());
//        List<Model> list = new com.activeandroid.query.Select().from(Student2.class).execute();
        List<Model> list = new com.activeandroid.query.Select().from(Student2.class).limit("0, 100000").execute();
//        List<Student2> list = new com.activeandroid.query.Select().from(Student2.class).where("Score > ? and Score < 50000", "1000").limit("1000, 100").execute();
//        assertEquals(list.size(), new com.activeandroid.query.Select().from(Student2.class).count());
    }
 
Example 8
Source File: CacheTest.java    From clear-todolist with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void setUp() {
    Configuration conf = new Configuration.Builder(getContext())
            .setDatabaseName("CacheTest")
            .addModelClasses(CacheTestModel.class, CacheTestModel2.class)
            .create();
    ActiveAndroid.initialize(conf, true);
}
 
Example 9
Source File: CommonApplication.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    // Create global configuration and initialize ImageLoader with this configuration
    ImageLoaderConfiguration config = UniversalImageLoader.getDefaultImageLoaderConfiguration(getApplicationContext());
    ImageLoader.getInstance().init(config);

    ActiveAndroid.initialize(this);

}
 
Example 10
Source File: JoH.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
public static void fullDatabaseReset() {
    try {
        clearCache();
        ActiveAndroid.dispose();
        ActiveAndroid.initialize(xdrip.getAppContext());
    } catch (Exception e) {
        Log.e(TAG,"Error restarting active android db");
    }
}
 
Example 11
Source File: PerfTestActiveAndroid.java    From android-database-performance with Apache License 2.0 5 votes vote down vote up
@Override
protected void doIndexedStringEntityQueries() throws Exception {
    // set up database
    Configuration dbConfiguration = new Configuration.Builder(getTargetContext())
            .setDatabaseName(DATABASE_NAME)
            .addModelClass(IndexedStringEntity.class)
            .create();
    ActiveAndroid.initialize(dbConfiguration);
    log("Set up database.");

    for (int i = 0; i < RUNS; i++) {
        log("----Run " + (i + 1) + " of " + RUNS);
        indexedStringEntityQueriesRun(getBatchSize());
    }
}
 
Example 12
Source File: JoH.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
public static void fullDatabaseReset() {
    try {
        clearCache();
        ActiveAndroid.dispose();
        ActiveAndroid.initialize(xdrip.getAppContext());
    } catch (Exception e) {
        Log.e(TAG,"Error restarting active android db");
    }
}
 
Example 13
Source File: PerfTestActiveAndroid.java    From android-database-performance with Apache License 2.0 5 votes vote down vote up
@Override
protected void onRunSetup() throws Exception {
    super.onRunSetup();

    // set up database
    Configuration dbConfiguration = new Configuration.Builder(getTargetContext())
            .setDatabaseName(DATABASE_NAME)
            .addModelClass(SimpleEntityNotNull.class)
            .create();
    ActiveAndroid.initialize(dbConfiguration);
}
 
Example 14
Source File: TestingApplication.java    From xDrip-plus with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onCreate() {
    xdrip.checkAppContext(RuntimeEnvironment.application);
    super.onCreate();
    ActiveAndroid.initialize(this);
}
 
Example 15
Source File: MyApp.java    From Study_Android_Demo with Apache License 2.0 4 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    ActiveAndroid.initialize(this);
}
 
Example 16
Source File: Application.java    From 10000sentences with Apache License 2.0 4 votes vote down vote up
private void initActiveAndroid() {
    ActiveAndroid.initialize(this);
}
 
Example 17
Source File: TestingApplication.java    From xDrip with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onCreate() {
    xdrip.checkAppContext(RuntimeEnvironment.application);
    super.onCreate();
    ActiveAndroid.initialize(this);
}
 
Example 18
Source File: Application.java    From clear-todolist with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onCreate() {
	super.onCreate();
	ActiveAndroid.initialize(this);
}
 
Example 19
Source File: AATest.java    From Storm with Apache License 2.0 4 votes vote down vote up
void open() {
    ActiveAndroid.initialize(getContext(), true);
}
 
Example 20
Source File: Application.java    From mobile-android-survey-app with MIT License 4 votes vote down vote up
@Override
public void onCreate() {
	super.onCreate();
	ActiveAndroid.initialize(this);
}