The app is to communicate with a bluetooth device with assorted data (config, measurements, service logs, status telemetry) - and it should cache obtained data so the user flipping between activities doesn't need to re-download everything when coming back to a prior activity, or the data was obtained in a prior activity (e.g. the "Summary" activity gets chunks of data from others).

That means a cache object which should hold this data - and be a single-instance class.

It's been hammered into my head that Singletons Are Bad. But with Android apps having multiple entry points, I can't guarantee a single initialization path for the app or the lifespan of the object, so I'm not sure if the singleton is still wrong here - or if so, how to approach getting the single-instance class right in this scenario. What form of single-instance object should I use, to initialize it on creation and access everywhere?

Xamarin, C#, if that's of importance.

1 Answer 1


In this case I would utilize a Singleton, created when the user first needs to read or write data, backed by a database. This Singleton could be provided through a dependency injection framework (and thus not be a real Singleton) but it depends on what xamarin can offer you.

Singletons are generally bad, but only because they tend to be overused and there is often a better solution to a given problem.

I am not sure what tools xamarin give you to work with a database.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.