Example:
Let assume we have one method ondiscover()
its call per mili second and find the data.
and save the data in one array temp_array
and push the data in Local DB callThreadToSavedataInLocalDB()
the callThreadToSavedataInLocalDB()
is slower than ondiscover()
after some time my temp_array
is full and app is crash. How to handle this problem.
how to increase the speed of data saving or if you have any other idea please suggest me.
i am giving you high level code idea how its work. ArrayList mapList; ArrayList tempList;
we have a method
ondiscover(arraylist arg)
{
tempList = addAll(arg) // make clone the arg list
if(tempList != null){
mapList = tempList;
tempList.clear();
if(not alive){
callThreadToSavedataInLocalDB(mapList); // Thread to save data in Sqlite
}
}
}
in Above code ondiscover called in very millisecond and callThreadToSavedataInLocalDB may take time to store data in local DB so at some time tempList have more data that may be crash the application.