Search in sources :

Example 31 with RealmConfiguration

use of io.realm.RealmConfiguration in project realm-java by realm.

the class TestRealmConfigurationFactory method copyRealmFromAssets.

// Copies a Realm file from assets to temp dir
public void copyRealmFromAssets(Context context, String realmPath, String newName) throws IOException {
    RealmConfiguration config = new RealmConfiguration.Builder().directory(getRoot()).name(newName).build();
    copyRealmFromAssets(context, realmPath, config);
}
Also used : RealmConfiguration(io.realm.RealmConfiguration)

Example 32 with RealmConfiguration

use of io.realm.RealmConfiguration in project realm-java by realm.

the class JNITableTest method getName.

@Test
public void getName() {
    String TABLE_NAME = "tableName";
    RealmConfiguration configuration = configFactory.createConfiguration();
    Realm.deleteRealm(configuration);
    SharedRealm sharedRealm = SharedRealm.getInstance(configuration);
    //noinspection TryFinallyCanBeTryWithResources
    try {
        // Writes transaction must be run so we are sure a db exists with the correct table.
        sharedRealm.beginTransaction();
        sharedRealm.getTable(TABLE_NAME);
        sharedRealm.commitTransaction();
        Table table = sharedRealm.getTable(TABLE_NAME);
        assertEquals(TABLE_NAME, table.getName());
    } finally {
        sharedRealm.close();
    }
}
Also used : RealmConfiguration(io.realm.RealmConfiguration) Test(org.junit.Test)

Example 33 with RealmConfiguration

use of io.realm.RealmConfiguration in project realm-java by realm.

the class SortDescriptorTests method setUp.

@Before
public void setUp() {
    RealmConfiguration config = configFactory.createConfiguration();
    sharedRealm = SharedRealm.getInstance(config);
    sharedRealm.beginTransaction();
    table = sharedRealm.getTable("test_table");
}
Also used : RealmConfiguration(io.realm.RealmConfiguration) Before(org.junit.Before)

Example 34 with RealmConfiguration

use of io.realm.RealmConfiguration in project xabber-android by redsolution.

the class DatabaseManager method configureRealm.

private void configureRealm() {
    RealmConfiguration config = new RealmConfiguration.Builder(Application.getInstance()).name(REALM_DATABASE_NAME).schemaVersion(REALM_DATABASE_VERSION).build();
    Realm.setDefaultConfiguration(config);
}
Also used : RealmConfiguration(io.realm.RealmConfiguration)

Example 35 with RealmConfiguration

use of io.realm.RealmConfiguration in project MPAndroidChart by PhilJay.

the class RealmMainActivity method onCreate.

@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();
}
Also used : RealmConfiguration(io.realm.RealmConfiguration) ListView(android.widget.ListView) ArrayList(java.util.ArrayList) MyAdapter(com.xxmassdeveloper.mpchartexample.notimportant.MyAdapter) Realm(io.realm.Realm) ContentItem(com.xxmassdeveloper.mpchartexample.notimportant.ContentItem)

Aggregations

RealmConfiguration (io.realm.RealmConfiguration)64 Realm (io.realm.Realm)20 DynamicRealm (io.realm.DynamicRealm)17 Scheduler (io.reactivex.Scheduler)14 RealmChangeListener (io.realm.RealmChangeListener)8 BeforeExperiment (dk.ilios.spanner.BeforeExperiment)6 Before (org.junit.Before)5 DynamicRealmObject (io.realm.DynamicRealmObject)4 RealmList (io.realm.RealmList)4 RealmResults (io.realm.RealmResults)4 ArrayList (java.util.ArrayList)4 Test (org.junit.Test)4 Context (android.content.Context)3 OrderedCollectionChangeSet (io.realm.OrderedCollectionChangeSet)3 OrderedRealmCollectionChangeListener (io.realm.OrderedRealmCollectionChangeListener)3 RealmObjectSchema (io.realm.RealmObjectSchema)3 AllTypes (io.realm.entities.AllTypes)3 IntentFilter (android.content.IntentFilter)2 LinearLayout (android.widget.LinearLayout)2 RealmSchema (io.realm.RealmSchema)2