If you are looking forward to get previous data, the following Codelab might help you. But this really depends on your implementation.
How to get previous stored data without using LiveData ?
How to get all rows stored in theroom
library usingAsync Task
?
Explanation:
In Your Dao include the following code:
@Query("SELECT * FROM user")
List<CustomObject> getAll();
In your Repository class include this snippet:
public List<CustomObject> getAll() throws ExecutionException, InterruptedException {
return new getAllAsyncTask(mCustomObjectDao).execute().get();
}
private static class getAllAsyncTask extends android.os.AsyncTask<Void, Void, List<CustomObject>> {
private CustomObjectDao mAsyncTaskDao;
List<CustomObject> a;
getAllAsyncTask(CustomObjectDao dao) {
mAsyncTaskDao = dao;
}
@Override
protected List<CustomObject> doInBackground(Void... voids) {
return mAsyncTaskDao.getAll();
}
}
solved How to get all rows stored in the `room` library using `Async Task`?