Skip to content

Instantly share code, notes, and snippets.

@husaynhakeem
Created September 27, 2017 14:46
Show Gist options
  • Save husaynhakeem/cc9a2a94a7d7aa20da08ce863d1432a0 to your computer and use it in GitHub Desktop.
Save husaynhakeem/cc9a2a94a7d7aa20da08ce863d1432a0 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