Skip to content

Instantly share code, notes, and snippets.

@husaynhakeem
Created September 27, 2017 14:45
Show Gist options
  • Save husaynhakeem/e1c6047dcbdb795e6452496d6f3b165a to your computer and use it in GitHub Desktop.
Save husaynhakeem/e1c6047dcbdb795e6452496d6f3b165a to your computer and use it in GitHub Desktop.
@Database(entities = {Pokemon.class}, version = 1)
public abstract class PokemonDataBase extends RoomDatabase {
private static final String POKEMON_DB = "pokemon.db";
public abstract PokemonDao pokemonDao();
private static PokemonDataBase pokemonDB;
public static PokemonDataBase getInstance(Context context) {
if (pokemonDB == null) {
pokemonDB = Room.databaseBuilder(context.getApplicationContext(), PokemonDataBase.class, POKEMON_DB).build();
}
return pokemonDB;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment