I have used applyBatch for insert,update and delete operation on SQLite database,there are more than 2000 entries for first time installation of app and for periodic sync too,due to large number of operation on database application get stop responding. applyBatch take approx 30-40 second for completion.
I have seen solution ContentResolver.bulkInsert (Uri url, ContentValues[] values) from Insertion of thousands of contact entries using applyBatch is slow
but it's for insert operation only,i have combination of query insert,update and delete.
i have also try to use AsyncTask
private class InsertTask extends AsyncTask<ArrayList<ContentProviderOperation>, Integer, Void> {
@Override
protected Void doInBackground(ArrayList<ContentProviderOperation>... params) {
try {
providerClient.applyBatch(params[0]);
} catch (RemoteException e) {
e.printStackTrace();
} catch (OperationApplicationException e) {
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(Void aVoid) {
super.onPostExecute(aVoid);
}
}
Thank you.