0

I m fetching data from my current activity but inserting it from background service. it get crashed while it does both inserting and fetching at same time. how to resolve this issue? The issue is that there is large ammount of data that i m storing it in data base by calling through service with small packet and updating my table info. At the same time if user navigate my visible acitvity and fetch date from table it will get Error Database is lock Exception. So i just want to get data from table as well as inserting it in same table. please give me any solution.

abhi
  • 759
  • 6
  • 15

2 Answers2

2

ContentProvider may solve your problem.

Reference : Android threading and database locking

Please go through comments of answer in above question.

Community
  • 1
  • 1
hemu
  • 3,199
  • 3
  • 44
  • 66
  • i have used synchronise anonymous keyword for that so is there any solution without content provider , because it also do same job as content provider – abhi Jun 20 '13 at 09:07
1

This may be happening because you are trying to fetch the same data form two threads (one the main thread and the other background thread) at the same time. You will have to make sure there is no such clash. you will have to use locking to avoid this clash. Exact problem can be find out if you can share the code.

nitigyan
  • 484
  • 2
  • 5
  • 18