I've created an app containing multiple databases and I need to use Kinvey for maintaining this data. Currently, I'm storing all the data locally using sqlite. I can write code to sync myself, but it would be much better just to let Kinvey do it. When I'm not trying to use Cache and Offline, the data is written properly to the Kinvey database...I can verify this through the web console. When I try to add the two lines of code for cache and offline policy, nothing gets written to Kinvey db and I get an error similar to what is shown below. This is just part of the logcat error. There appears to be some problem with offline user login?? I included some simple code below that reproduces the problem I'm having. I've read the guides on the website many times, and I just seem to be overlooking something. I added the services and permission to manifest as the guide stated. I don't know what else to try or where else to go. Any ideas as to what I'm doing wrong? Thanks.
AsyncAppData gear = kinveyClient.appData("myCollection",
MyEntity.class);
gear.setCache(new InMemoryLRUCache(), CachePolicy.CACHEFIRST);
gear.setOffline(OfflinePolicy.LOCAL_FIRST, new SqlLiteOfflineStore(this));
kinveyClient.user().login(username, password, new KinveyUserCallback() {
@Override
public void onFailure(Throwable arg0) {
}
@Override
public void onSuccess(User arg0) {
}
});
MyEntity event = new MyEntity();
event.setTitle("Launch Party");
gear.save(event, new KinveyClientCallback() {
@Override
public void onFailure(Throwable arg0) {
}
@Override
public void onSuccess(MyEntity arg0) {
Toast.makeText(getApplicationContext(),
"Object saved is: " + arg0.getTitle(),
Toast.LENGTH_LONG).show();
}
});
kinveyClient.user().logout().execute();
This is part of the LogCat error:
01-20 15:42:15.257: E/SQLiteDatabase(6992): Error inserting json={"Title":"Launch Party","id":"5e8684e321664fa797f4d1cf53f55082"} deleted=0 _id=5e8684e321664fa797f4d1cf53f55082 _user=null 01-20 15:42:15.257: E/SQLiteDatabase(6992): android.database.sqlite.SQLiteConstraintException: offlinemyCollection._user may not be NULL (code 19)