I'm trying to get data from databse in a listview as shown below.
long count = UserTableSugar.count(UserTableSugar.class);
if(count>0)
{
UserTableSugar.listAll(UserTableSugar.class);
List<UserTableSugar> userTable = UserTableSugar.listAll(UserTableSugar.class);
CustomAdapterListview madapter = new CustomAdapterListview(getApplicationContext(),userTable);
listView.setAdapter(madapter);
}
but,the data won't show up. On debugging, the value of count is 2 (there are two records in table). But the size of list userTable is shown 0.
SOLVED : Adding empty constructor of the model class did the trick.
With SugarORM, all model classes need an empty constructor or they cannot be used.
UserTableSugar() {}
will do the job!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With