0

I'm building an android app who needs to present lots of data received from the web.

Due to the fact that it might take a long time to retrieve all the data and that the user might close the app before the process ends, I've thought about implementing it in a 'Service', store the data within a 'Content Provider' and then to query it from the app when needed.

It's also needed that when new data received, the app gets a notification like an invoked function. Is it available in this pattern?

Is it all right? And if not, What's the best design that matched this problem?

Thanks a lot!

AMM
  • 2,195
  • 2
  • 20
  • 28

1 Answers1

1

Yes,using a content provider like.. sqlite database.. will suit the situation you are explaining... If you use a sqlite database.. be careful while accessing data... because your service will be updating the database..

5hssba
  • 8,079
  • 2
  • 33
  • 35
  • Tnx but what about the updates? How can I notify the app (if it's running) that something has been added? – AMM Mar 20 '12 at 12:29
  • 1
    I was thinking... if you have something to update into the database in your service.. then send a broadcast.. and implement a receiver in your activity... now when nothing to update.. send a broadcast again..after you get the second broadcast only.. your application should access the database.. – 5hssba Mar 20 '12 at 12:32
  • Thanks but I can't wait for all the updates, I need to present the data that already received even if its partial. Is that a problem to access the data from the service and the activity? – AMM Mar 20 '12 at 13:00
  • 1
    se this question... http://stackoverflow.com/questions/9786915/android-how-to-stop-database-insertion-process/9787225#9787225 – 5hssba Mar 20 '12 at 13:02
  • ok but if I just want to read data from the DB and not to change anything, is it still necessary? – AMM Mar 20 '12 at 13:10
  • 1
    When a read operation begins on a WAL-mode database, it first remembers the location of the last valid commit record in the WAL. Call this point the "end mark". Because the WAL can be growing and adding new commit records while various readers connect to the database, each reader can potentially have its own end mark. But for any particular reader, the end mark is unchanged for the duration of the transaction, thus ensuring that a single read transaction only sees the database content as it existed at a single point in time.see the concurrency part of this http://www.sqlite.org/draft/wal.html – 5hssba Mar 21 '12 at 04:08