In my Android application after successful login I'm saving session info in Room, then I'm retrieving user information from BE and saving it too. Everything works fine. I can see saved information in database tables.
When user logs out from application all tables are being cleared with appDatabase.clearAllTables() method call.
The catch is that on subsequent login there's no information that is being inserted in DB but my Rx calls aren't throwing any errors.
I've tried to use logging and debug but everything looks like normal.
Logging shows following actions being performed: login -> get user info from BE -> save session -> save user.
When debugging I can see that user info is being handled in UserDao_Impl's insertUser() method.
In application I use RxJava2 version 2.2.2, Room persistence library version 1.1.1, dependencies are being provided with Dagger version 2.19.
Here's my code snippets:
LoginUserUseCase.java
public Completable execute(@NonNull LoginInfo loginInfo) {
Completable loginAndSaveSession = sessionRepository.loginUser(loginInfo)
.flatMapCompletable(
session -> sessionRepository.saveSession(
session));
Completable getAndSaveUserInfo = userRepository.getRemoteUserInfo()
.flatMapCompletable(
user -> userRepository.saveUser(
user));
return loginAndSaveSession.andThen(getAndSaveUserInfo);
}
UserRepository.java
public Completable saveUser(@NonNull User user) {
return Completable.fromAction(() -> userDao.insertUser(user));
}
UserDao.java
@Insert(onConflict = OnConflictStrategy.REPLACE)
void insertUser(User user);
LogoutUserUseCase.java
public Completable execute() {
return Completable.fromAction(() -> appDatabase.clearAllTables());
}
UPDATE (ISSUE RESOLVED): wasted a day on this bug. Finally come to understanding that some other library can affect application's work with Room. Turned out that Android Debug Database library that I've used to peek inside the database on device has a bug that breaks DB after you opened it once with its help.
Returning back to Stetho.
UserRepository#saveUser()
can returnCompletable
ifUserDao#insertUser()
return nothing (void). Do you have special wrapper? – WaldoclearAllTables()
was made in the app. The inserting into DB is compromised. Tested on Android Studio Bumblebee | 2021.1.1 Patch 2 Windows 10 – Blackness