androiddatabasedbflow

DBFlow - update multiple items efficiently


ArrayList list =... --> Get data from database

//do some changes in the values of the objects in the list

for(MyObject object:list){ object.save(); }

Instead of this for loop is there a way to save multiple items that is more efficient than calling save() a bunch of times?


Solution

  • Finaly found it

    FlowManager.getModelAdapter(MyTable.class).saveAll(myObjectsList);
    

    and it's faster than calling save multiple times. From some quick testing for 15 items the multiple save took an average of 120 milliseconds while saveAll took about 100 milliseconds. percentage wise it's quite a big difference.