@Override public void onCreate() { super.onCreate(); boxStore = MyObjectBox.builder().androidContext(App.this).build(); daoSession = new DaoSession(boxStore); }
@Override public void onCreate() { super.onCreate(); boxStore = MyObjectBox.builder().androidContext(App.this).build(); if (BuildConfig.DEBUG) { new AndroidObjectBrowser(boxStore).start(this); } }
@Override public void onCreate() { super.onCreate(); boxStore = MyObjectBox.builder().androidContext(App.this).build(); if (BuildConfig.DEBUG) { new AndroidObjectBrowser(boxStore).start(this); } Log.d("App", "Using ObjectBox " + BoxStore.getVersion() + " (" + BoxStore.getVersionNative() + ")"); }
public static void main(String[] args) { BoxStore store = MyObjectBox.builder().name("objectbox-notes-db").build(); Box<Note> box = store.boxFor(Note.class); String text = args.length > 0 ? String.join(" ", args) : "No text given"; box.put(new Note(text)); System.out.println(box.count() + " notes in ObjectBox database:"); for (Note note : box.getAll()) { System.out.println(note); } store.close(); } }
@Before public void setUp() throws IOException { // store the database in the systems temporary files folder File tempFile = File.createTempFile("object-store-test", ""); // ensure file does not exist so builder creates a directory instead tempFile.delete(); boxStoreDir = tempFile; store = MyObjectBox.builder().directory(boxStoreDir).build(); }
@Before public void setUp() throws Exception { // delete database files before each test to start with a clean database BoxStore.deleteAllFiles(TEST_DIRECTORY); store = MyObjectBox.builder() // add directory flag to change where ObjectBox puts its database files .directory(TEST_DIRECTORY) // optional: add debug flags for more detailed ObjectBox log output .debugFlags(DebugFlags.LOG_QUERIES | DebugFlags.LOG_QUERY_PARAMETERS) .build(); }