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.
Asked
Active
Viewed 531 times
0
-
1post some code for us to understand your problem better – 7bluephoenix Jun 20 '13 at 04:58
-
2first insert data and then fetch.. – Sagar Maiyad Jun 20 '13 at 04:58
-
You can't fetch data before it is inserted..how on earth you can do that? You have to have data in the table to fetch it..so insert data first and then try n fetch it – Mayank Saini Jun 20 '13 at 07:55
-
i have inserted data by it also updating table in background due to reason of large data to store it in background, and fetched while called by activity – abhi Jun 20 '13 at 09:02
2 Answers
2
ContentProvider
may solve your problem.
Reference : Android threading and database locking
Please go through comments of answer in above question.
-
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