Skip to content

Instantly share code, notes, and snippets.

@BrantApps
Created November 9, 2018 23:55
Show Gist options
  • Save BrantApps/4d18b8f86e9740c4f91a0cc2f14b9db1 to your computer and use it in GitHub Desktop.
Save BrantApps/4d18b8f86e9740c4f91a0cc2f14b9db1 to your computer and use it in GitHub Desktop.
An older way of doing in-memory dbs on Android without Room.
package com.brantapps.oceanlife.domain.fixture;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import org.robolectric.RuntimeEnvironment;
/**
* In memory database for testing purposes.
*
* Created by davidb on 29/09/15.
*/
public class InMemoryDatabase extends SQLiteOpenHelper {
public InMemoryDatabase(int version) {
super(RuntimeEnvironment.application, null, null, version);
}
@Override
public void onCreate(SQLiteDatabase db) {
// No-op test db! - fixtures will be added by the tests cases
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
// No-op test db!
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment