sqlite - Android Async Task execution -


in android async tasks, code executed sequentially, or there optimizations? ask because experienced strange behaviour batch of contentprovideroperations execute in asynct task. asking doinbackground method other 2 executed on ui thread.

edit: strange behaviour following: have 3 tables, 1 has primary key foreign key int other two, , other 2 independent between each other. when want delete go first deleting rows of independent tables in order remove foreign key constraint in first one, can delete there well. inserting other way around, first create row in 1st table, create primary key other 2 can reference, , create row in other two.

all of put in batch of content provider operation, constraint failed response.

edit2: of in single thread, in doinbackground of single asynctask , here code ( problem 1 has fk other two:

for (actionsyncmodel ac : res.actions_table) {                     uri deleteuri = actioncontract.action.content_uri                             .buildupon()                             .appendpath(integer.tostring(ac.oldid)).build();                     string temp = deleteuri.tostring();                     log.i("action delete ->>>> ", temp);                     batch.add(contentprovideroperation.newdelete(deleteuri)                             .build());                     getcontentresolver().delete(deleteuri, null, null);                 }                  (journalattachmentsyncmodel js : res.attach_table) {                      uri deleteuri = journalattachmentcontract.journalattachment.content_uri                             .buildupon()                             .appendpath(integer.tostring(js.oldid)).build();                     string temp = deleteuri.tostring();                     log.i("attach delete ->>>>", temp);                     batch.add(contentprovideroperation.newdelete(deleteuri)                             .build());                     getcontentresolver().delete(deleteuri, null, null);                 }                  (problemsyncmodel pro : res.problems_table) {                      uri deleteuri = problemcontract.problem.content_uri                             .buildupon()                             .appendpath(integer.tostring(pro.oldid))                             .build();                     string temp = deleteuri.tostring();                     log.i("problem delete->>>>", temp);                     batch.add(contentprovideroperation.newdelete(deleteuri)                             .build());                     getcontentresolver().delete(deleteuri, null, null);                 } 

thank you

from code above, seems batch operation not execute in end. need getcontentresolver().applybatch(...) run in bath. otherwise, deletes executed independently in individual transaction instead of single transaction.

but may not explain constraint error. may more schema.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -