forked from github/wulkanowy-mirror
Clear db before register (#121)
This commit is contained in:
parent
3592946e6f
commit
ef648c7f8b
@ -2,6 +2,8 @@ package io.github.wulkanowy.data.sync;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import org.greenrobot.greendao.database.Database;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
@ -11,6 +13,7 @@ import javax.inject.Singleton;
|
||||
import io.github.wulkanowy.api.Vulcan;
|
||||
import io.github.wulkanowy.api.VulcanException;
|
||||
import io.github.wulkanowy.data.db.dao.entities.Account;
|
||||
import io.github.wulkanowy.data.db.dao.entities.DaoMaster;
|
||||
import io.github.wulkanowy.data.db.dao.entities.DaoSession;
|
||||
import io.github.wulkanowy.data.db.dao.entities.Diary;
|
||||
import io.github.wulkanowy.data.db.dao.entities.DiaryDao;
|
||||
@ -49,6 +52,8 @@ public class AccountSync {
|
||||
public void registerUser(String email, String password, String symbol)
|
||||
throws VulcanException, IOException, CryptoException {
|
||||
|
||||
clearUserData();
|
||||
|
||||
vulcan.setCredentials(email, password, symbol, null, null, null);
|
||||
|
||||
daoSession.getDatabase().beginTransaction();
|
||||
@ -152,4 +157,11 @@ public class AccountSync {
|
||||
diary.getValue()
|
||||
);
|
||||
}
|
||||
|
||||
private void clearUserData() {
|
||||
Database database = daoSession.getDatabase();
|
||||
DaoMaster.dropAllTables(database, true);
|
||||
DaoMaster.createAllTables(database, true);
|
||||
sharedPref.setCurrentUserId(0);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user