android - How to speed up loading of data from three different tables and showing in a view pager with three fragments? -


as observed whatsapp load instantly reading local database of datas of 3 categories of chats, calls , contacts. have 3 similar fragment of 3 categories whatsapp inside viewpager. need first read , sort data well. see significant amount of load time. approach read data 3 db , sorting , hence loading viewpager adapter.

what step can improve load time? lot in advance answer.

here code reference

    class readdataasync {     asynctask<void, void, void> readdatafromdbtask = new asynctask<void, void, void>() {         @override         protected void doinbackground(void... params) {             billslist.clear();              itemlist.clear();              customerlist.clear();              billslist = snappydbutil.getallbillsfromdb();              itemlist = snappydbutil.getarrayofobjectfromkeys(dbname.items.name(), itemeb.class);              customerlist = snappydbutil.getallcustomersfromdb();             return null;         }          @override         protected void onpreexecute() {             super.onpreexecute();             log.i("time", "start time " + system.currenttimemillis());         }          @override         protected void onpostexecute(void avoid) {             super.onpostexecute(avoid);               collections.sort(itemlist, itemeb.itemebcomparator);             collections.sort(customerlist, customereb.namecomparator);             collections.sort(billslist, billeb.billscomparator);              if (billsfragment != null)                 billsfragment.getbillsadapter().notifydatasetchanged();              if (itemfragment != null)                 itemfragment.getitemslistadapter().notifydatasetchanged();              if (contactsfragment != null)                 contactsfragment.getcustomerlistadapter().notifydatasetchanged();               if (viewpageradapter != null) {                 mviewpager.setadapter(viewpageradapter);                 mviewpager.setcurrentitem(1);             }             log.i("time", "stop time " + system.currenttimemillis());           }     }; } 

without seeing code can give generic answers.

one thing thought of make database sorting using order by in sql

another should doing reading database on separate thread. asynctask way started in android threading if you're new it


Comments

Popular posts from this blog

routing - AngularJS State management ->load multiple states in one page -

python - GRASS parser() error -

Swift game error message -