Li Feng, chief designer at the China Academy of Space Technology's communication satellite division, said the technology BEING TESTED IN ORBIT RIGHT NOW is «in the latter stages of the proof-of-principle phase» with the goal of making it available in satellites «as quickly as possible.»
«Although it is difficult to do this, we have the confidence that we will succeed,» he said.
Отвечу сначала на второй вопрос: Как видно из кода в моем посте PreferencesHelper инициализируется с использованием контекста Application в методе onCreate наследника класса Application, а не Activity или фрагмента.
«Application.onCreate called when the application is starting, before any activity, service, or receiver objects (excluding content providers) have been created. »
и т.о. метод initInstance вызывается один раз и инициализирует static INSTANCE соответственно тоже один раз при старте процесса приложения.
Метод getInstance просто getter, предоставляющий доступ к INTANCE. Все время используется один и тот же SharedPreferences, который получен при старте приложения.
«Although it is difficult to do this, we have the confidence that we will succeed,» he said.
«Application.onCreate called when the application is starting, before any activity, service, or receiver objects (excluding content providers) have been created. »
и т.о. метод initInstance вызывается один раз и инициализирует static INSTANCE соответственно тоже один раз при старте процесса приложения.
Метод getInstance просто getter, предоставляющий доступ к INTANCE. Все время используется один и тот же SharedPreferences, который получен при старте приложения.
Для классической реализации синглтон, конструктор private и чтобы избежать проблем добавить synchronized в метод getInstance
или что мне больше нравится, разделить метод getInstance на два метода initInstance и getInstance: