Skip to content

Instantly share code, notes, and snippets.

@MwBakker
Created September 28, 2018 12:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MwBakker/1659873db95485630123f4816c83c554 to your computer and use it in GitHub Desktop.
Save MwBakker/1659873db95485630123f4816c83c554 to your computer and use it in GitHub Desktop.
// inner-class, extends possibility of async (since only one can be extended at the time)
// private so can't be a loose-filed class..
// populates the DB with a dao coming from other thread(?)
private static class PopulateDbAsync extends AsyncTask<Void, Void, Void> {
private final StorageDao sDao;
PopulateDbAsync(StorageDatabase db) { sDao = db.storageDao(); }
@Override
protected Void doInBackground(final Void... params) {
sDao.deleteAll();
Storage storage = new Storage();
sDao.insert(storage);
storage = new Storage();
sDao.insert(storage);
return null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment