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);
}
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();
}
}
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");
}
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);
}
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();
}
Aggregations