I use Realm to provide a database for my application. But...
After entering the system, the server returns the data, and I create an account (AccountManager) and save this data in the application database, for example (in AsyncTask, of course):
UserRealm userRealm = new UserRealm();
After that, I close LoginActivity and in onResume from MainActivity, I try to load the user like this (in AsyncTask, again ...):
public static UserRealm getUser(Context context) { try { return Realm.getInstance(context).where(UserRealm.class).findFirst(); } catch (Exception e) { if(DebugUtil.DEBUG) {
But this returns null, I do not know what is happening to it.
UserRealm: https://gist.github.com/ppamorim/88f2553a6ff990876bc6
source share