Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sugar ORM listAll() not showing any data

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.

like image 533
Aakash Joshi Avatar asked Jun 15 '16 11:06

Aakash Joshi


1 Answers

With SugarORM, all model classes need an empty constructor or they cannot be used.

UserTableSugar() {} will do the job!

like image 99
Jake Lee Avatar answered Oct 15 '22 05:10

Jake Lee