views:

357

answers:

2

Does the calendar application in Android maintain a cache of its database? Whenever I edit and mark some events via the calendar app, it is stored in the database but if I edit the calendar.db from some outside source the changes made are not reflected in the calendar app. So my question is:

  • Does the calendar app maintain a cache or some other form of database?
  • If yes then where and how?
A: 

It is quite plausible that the Calendar application keeps the values that it has displayed in memory. It might be that if you track back and forth - far enough - then it forgets some value and then when you go back again, it would pick up the value from the externally edited database. However, if it flushes the in-memory modified value before jettisoning the value from memory, then it would overwrite the externally edited value before continuing. (I'm not convinced it would only write the in-memory value when it needed to jettison the value; I would expect it to write the value to the database reasonably soon after the value is edited - like when the calendar entry is saved.)

On the other hand, it might be completely different from that.

Jonathan Leffler
A: 

One thing I can think of, is to use the permission to allow access to the phone's Calendar in the external app(non-calendar app), and that permission is:

WRITE_CALENDAR

Similarly, if you try to read from that same external app, you may get bad values(or null values) without the associated read permission:

READ_CALENDAR

However, if it's a homebrew calendar, pet project or other, you need to make sure that the database being used will also allow other users to write to it, thought I can't remember exactly how to do that right now.

As far as cache goes, the phone shouldn't be caching a lot of database information, especially since its SQLite. A cache, in theory, would hold temporary data, or commonly used data(like an index), but it wouldn't store tuples from the database itself, and modifying the cache would require the change to be committed to the database anyhow. Perhaps I'm completely wrong on this though.

rhunex