Question

My app has these parts

A. Main activity
B. Widget provider
C. Sync Adapter  (talks to the cloud)
D. Local persisted data (small, about 1-2KB).

A,B,C read/write from/to D. The app does not interact with other apps and all the parts are in a single apk.

  1. Can I implement the storage D as a singleton of a class with plain Java API that is not a ContentProvider? (I prefer not to use SQLite but a single flat file that I manage, this code and a proprietary API already exists. Adding proper synchronization should not be a problem).

  2. Are all the parts A,B,C,D guaranteed to run in the same process and same class loader, sharing the same singletons?

  3. Currently the app does not have an Application class. Should add one and tie the D singleton to it or is there is no real need to have an Application class?

  4. Anything else I should be aware of?

Was it helpful?

Solution

Can I implement the storage D as a singleton of a class with plain Java API that is not a ContentProvider? (I prefer not to use SQLite but a single flat file that I manage, this code and a proprietary API already exists. Adding proper synchronization should not be a problem).

Yes you can.

Are all the parts A,B,C,D guaranteed to run in the same process and same class loader, sharing the same singletons?

Yes if they are in the same application (so defined in the same AndroidManifest)

Currently the app does not have an Application class. Should add one and tie the D singleton to it or is there is no real need to have an Application class?

No you do not need it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top