當前位置: 首頁>>代碼示例>>Java>>正文


Java Realm.setDefaultConfiguration方法代碼示例

本文整理匯總了Java中io.realm.Realm.setDefaultConfiguration方法的典型用法代碼示例。如果您正苦於以下問題:Java Realm.setDefaultConfiguration方法的具體用法?Java Realm.setDefaultConfiguration怎麽用?Java Realm.setDefaultConfiguration使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在io.realm.Realm的用法示例。


在下文中一共展示了Realm.setDefaultConfiguration方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onCreate

import io.realm.Realm; //導入方法依賴的package包/類
@Override
public void onCreate() {
    super.onCreate();

    Realm.init(this);
    RealmConfiguration config = new RealmConfiguration.Builder()
            .deleteRealmIfMigrationNeeded()
            //.schemaVersion(2) // Must be bumped when the schema changes
            //.migration(new RealmContactMigration()) // Migration to run instead of throwing an exception
            .name("default.realm").build();
    Realm.setDefaultConfiguration(config);

    if(database==null) {
        FirebaseDatabase.getInstance().setPersistenceEnabled(true);
        FirebaseDatabase.getInstance().setLogLevel(Logger.Level.DEBUG);
    }

    database = FirebaseDatabase.getInstance();
    References.init(this, database);

    AppManager.getInstance().setContext(getApplicationContext());
    AppManager.getInstance().setCountry(Country.getCountryFromSIM(getApplicationContext()));

    // Initialize image loader
    initImageLoader(this);
}
 
開發者ID:AppHero2,項目名稱:Raffler-Android,代碼行數:27,代碼來源:AppApplication.java

示例2: onCreate

import io.realm.Realm; //導入方法依賴的package包/類
@Override
public void onCreate() {
    super.onCreate();
    random = new Random();
    xkcdMapper = new XkcdMapper();
    executor = Executors.newSingleThreadExecutor();
    Realm.init(this);
    RealmConfiguration realmConfiguration = new RealmConfiguration.Builder() //
            .deleteRealmIfMigrationNeeded() //
            .build();
    Realm.setDefaultConfiguration(realmConfiguration);
    retrofit = new Retrofit.Builder().baseUrl("http://xkcd.com/")
            .addConverterFactory(LoganSquareConverterFactory.create())
            .build();
    xkcdService = retrofit.create(XkcdService.class);
}
 
開發者ID:Zhuinden,項目名稱:xkcd-example,代碼行數:17,代碼來源:CustomApplication.java

示例3: onCreate

import io.realm.Realm; //導入方法依賴的package包/類
@Override
public void onCreate() {
    super.onCreate();
    application = this;

    Nammu.init(this);

    /*
     * Configure Realm
     */
    Realm.init(this);
    RealmConfiguration realmConfiguration = new RealmConfiguration.Builder()
            .deleteRealmIfMigrationNeeded()
            .build();

    Realm.setDefaultConfiguration(realmConfiguration);

    try {
        DataStore.getInstance();
    } catch (RealmError e) {
        Log.e(TAG, "Error configuring realm, deleting and trying again.", e);

        Realm.deleteRealm(realmConfiguration);
        DataStore.getInstance();
    }
}
 
開發者ID:KwalaGroup,項目名稱:Android-Client,代碼行數:27,代碼來源:KwalaApplication.java

示例4: Realm

import io.realm.Realm; //導入方法依賴的package包/類
public static Realm Realm() {
    if(realm == null){
        // Create a RealmConfiguration that saves the Realm file in the app's "files" directory.
        Realm.init(getAppContext());
        RealmConfiguration realmConfig = new RealmConfiguration.Builder()
                .deleteRealmIfMigrationNeeded()
                .build();
        Realm.setDefaultConfiguration(realmConfig);

        // Get a Realm instance for this thread
        realm = Realm.getDefaultInstance();

        realm.addChangeListener(new RealmChangeListener<Realm>() {
            @Override
            public void onChange(Realm element) {
                Log.d(Tag,"app realmOnChangeListener");
            }
        });
    }

    return realm;
}
 
開發者ID:jamesddube,項目名稱:LaravelNewsApp,代碼行數:23,代碼來源:App.java

示例5: onCreate

import io.realm.Realm; //導入方法依賴的package包/類
@Override
public void onCreate() {
    super.onCreate();
    cluttr=this;
    Colorful.defaults().translucent(true);
    Colorful.init(this);
    ExtSdHelper.init();
    prefs = PreferenceManager.getDefaultSharedPreferences(this);
    newRelease = !(BuildConfig.VERSION_CODE == prefs.getInt("current_version",0));

    Realm.init(this);
    RealmConfiguration config = new RealmConfiguration.Builder()
            .deleteRealmIfMigrationNeeded()
            .directory(getCacheDir())
            .build();
    Realm.setDefaultConfiguration(config);
}
 
開發者ID:garretyoder,項目名稱:Cluttr,代碼行數:18,代碼來源:Cluttr.java

示例6: onCreate

import io.realm.Realm; //導入方法依賴的package包/類
@Override
public void onCreate() {
    super.onCreate();
    mContext = getApplicationContext();

    Realm.init(this);
    RealmConfiguration config = new RealmConfiguration.Builder()
            .deleteRealmIfMigrationNeeded()
            .build();
    Realm.setDefaultConfiguration(config);
}
 
開發者ID:SimonCherryGZ,項目名稱:face-landmark-android,代碼行數:12,代碼來源:MyApplication.java

示例7: onCreate

import io.realm.Realm; //導入方法依賴的package包/類
@Override
public void onCreate() {
    super.onCreate();
    Realm.init(this);
    RealmConfiguration.Builder config = new RealmConfiguration.Builder()
            .name("kutuk.realm")
            .schemaVersion(SCHEMA_VERSION);
    if (BuildConfig.DEBUG) {
        config.deleteRealmIfMigrationNeeded();
    } else {
        config.migration(new Migration());
    }
    Realm.setDefaultConfiguration(config.build());
}
 
開發者ID:SeriousBug,項目名稱:Kutuk,代碼行數:15,代碼來源:KutukApp.java

示例8: initDefaultRealm

import io.realm.Realm; //導入方法依賴的package包/類
public static void initDefaultRealm(@NonNull String dbSuffix, int version, RealmMigration realmMigration) {
        Realm.removeDefaultConfiguration();
        RealmConfiguration.Builder builder = new RealmConfiguration.Builder()
                .name("db_realm_" + dbSuffix)
                .schemaVersion(version)
                .rxFactory(new RealmObservableFactory());
//                .deleteRealmIfMigrationNeeded();
        if (realmMigration != null)
            builder.migration(realmMigration);

        RealmConfiguration realmConfiguration = builder.build();
        Realm.setDefaultConfiguration(realmConfiguration);
    }
 
開發者ID:Jusenr,項目名稱:androidgithub,代碼行數:14,代碼來源:DBManager.java

示例9: onCreate

import io.realm.Realm; //導入方法依賴的package包/類
@Override
public void onCreate() {
    super.onCreate();
    Realm.init(this);
    RealmConfiguration configuration = new RealmConfiguration.Builder().deleteRealmIfMigrationNeeded().build();
    Realm.setDefaultConfiguration(configuration);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:8,代碼來源:MyApplication.java

示例10: onCreate

import io.realm.Realm; //導入方法依賴的package包/類
@Override
public void onCreate() {
    super.onCreate();
    context = this;

    initializeTimber();
    RxJavaPlugins.setErrorHandler(throwable -> Timber.e(throwable.toString()));

    // Configure default configuration for Realm
    Realm.init(this);
    RealmConfiguration realmConfig = new RealmConfiguration.Builder().build();
    Realm.setDefaultConfiguration(realmConfig);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:14,代碼來源:NewsReaderApplication.java

示例11: RealmSingleton

import io.realm.Realm; //導入方法依賴的package包/類
private RealmSingleton() {
    try {
        realm = Realm.getDefaultInstance();
    } catch (Exception e) {
        RealmConfiguration config = new RealmConfiguration.Builder(App.getAppContext())
                .name("tmsdb.realm")
                .schemaVersion(REALM_SCHEMA_VERSION)
                .migration(new MyRealmMigration())
                .build();
        Realm.setDefaultConfiguration(config);
        realm = Realm.getDefaultInstance();
    }
}
 
開發者ID:chashmeetsingh,項目名稱:TrackIt-Android,代碼行數:14,代碼來源:RealmSingleton.java

示例12: onCreate

import io.realm.Realm; //導入方法依賴的package包/類
@Override
    public void onCreate() {
        super.onCreate();

        //kode konfirmasi Realm
        RealmConfiguration config = new RealmConfiguration.Builder()
//                .deleteRealmIfMigrationNeeded()
//                .build();
                .schemaVersion(0)
                .migration(new DataMigration())
                .build();
        Realm.setDefaultConfiguration(config);
    }
 
開發者ID:setakarim,項目名稱:ingetin,代碼行數:14,代碼來源:BaseApp.java

示例13: initDatabase

import io.realm.Realm; //導入方法依賴的package包/類
private void initDatabase() {

		Realm.init(BikeDeBoaApplication.this);
		RealmConfiguration configuration = new RealmConfiguration.Builder()
				.deleteRealmIfMigrationNeeded()
				.build();
		Realm.setDefaultConfiguration(configuration);
	}
 
開發者ID:EduardoVernier,項目名稱:bikedeboa-android,代碼行數:9,代碼來源:BikeDeBoaApplication.java

示例14: onCreate

import io.realm.Realm; //導入方法依賴的package包/類
public void onCreate() {
    super.onCreate();
    Realm.init(this);

    config = new RealmConfiguration.Builder().name("posts").deleteRealmIfMigrationNeeded().build();
    Realm.setDefaultConfiguration(config);
}
 
開發者ID:ccrama,項目名稱:Slide-RSS,代碼行數:8,代碼來源:BaseApplication.java

示例15: onCreate

import io.realm.Realm; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.activity_main);

    setTitle("Realm.io Examples");

    ArrayList<ContentItem> objects = new ArrayList<ContentItem>();

    objects.add(new ContentItem("Line Chart", "Creating a LineChart with Realm.io database"));
    objects.add(new ContentItem("Bar Chart",
            "Creating a BarChart with Realm.io database"));
    objects.add(new ContentItem("Horizontal Bar Chart",
            "Creating a HorizontalBarChart with Realm.io database"));
    objects.add(new ContentItem("Scatter Chart",
            "Creating a ScatterChart with Realm.io database"));
    objects.add(new ContentItem("Candle Stick Chart", "Creating a CandleStickChart with Realm.io database"));
    objects.add(new ContentItem("Bubble Chart", "Creating a BubbleChart with Realm.io database"));
    objects.add(new ContentItem("Pie Chart", "Creating a PieChart with Realm.io database"));
    objects.add(new ContentItem("Radar Chart", "Creating a RadarChart with Realm.io database"));
    objects.add(new ContentItem("Realm Wiki", "This is the code related to the wiki entry about realm.io on the MPAndroidChart github page."));

    MyAdapter adapter = new MyAdapter(this, objects);

    ListView lv = (ListView) findViewById(R.id.listView1);
    lv.setAdapter(adapter);

    lv.setOnItemClickListener(this);

    Realm.init(this);

    // Create a RealmConfiguration that saves the Realm file in the app's "files" directory.
    RealmConfiguration realmConfig = new RealmConfiguration.Builder().build();
    Realm.setDefaultConfiguration(realmConfig);

    Realm realm = Realm.getDefaultInstance();
    realm.beginTransaction();
    realm.deleteAll();
    realm.commitTransaction();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:43,代碼來源:RealmMainActivity.java


注:本文中的io.realm.Realm.setDefaultConfiguration方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。