se.emilsjolander.sprinkles.Sprinkles Java Examples
The following examples show how to use
se.emilsjolander.sprinkles.Sprinkles.
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: MainApplication.java From AndroidDatabaseLibraryComparison with MIT License | 6 votes |
@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 #2
Source File: MyApplication.java From sprinkles with Apache License 2.0 | 4 votes |
@Override public void onCreate() { super.onCreate(); Sprinkles sprinkles = Sprinkles.init(getApplicationContext()); sprinkles.addMigration(new Migration() { @Override protected void onPreMigrate() { // do nothing } @Override protected void doMigration(SQLiteDatabase db) { db.execSQL( "CREATE TABLE Notes (" + "id INTEGER PRIMARY KEY AUTOINCREMENT,"+ "content TEXT,"+ "created_at INTEGER,"+ "updated_at INTEGER"+ ")" ); db.execSQL( "CREATE TABLE Tags (" + "id INTEGER PRIMARY KEY AUTOINCREMENT,"+ "name TEXT"+ ")" ); db.execSQL( "CREATE TABLE NoteTagLinks (" + "note_id INTEGER,"+ "tag_id INTEGER,"+ "PRIMARY KEY(note_id, tag_id),"+ "FOREIGN KEY(note_id) REFERENCES Notes(id) ON DELETE CASCADE,"+ "FOREIGN KEY(tag_id) REFERENCES Tags(id) ON DELETE CASCADE"+ ")" ); } @Override protected void onPostMigrate() { // do nothing } }); }