Are static variables truly “global” (system-wide) in Android?

A quick note at the very beginning to avoid false duplicates: there are many questions about when static variables are cleared and how long they live. This is not what I am asking here.

If I have a static variable in a program on a PC, and I run two different copies of the program, then each copy usually starts in its own sandbox with its own personal values ​​for its static variables. Thus, they are not system-wide global (not sure if this is a good terminology here).

Are there any situations in Android where I can have several “instances” (poorly used word) of a static variable? I don’t think it’s possible to have multiple copies of Activity running in parallel in different sandboxes (although I’m not sure about it), but what about ConentProviders, IntentServices or any other class that Android can accidentally create from potentially different processes?

Or, in other words, if I have a class with a static variable, I am sure that every instance of the class existing on the same device has access to the exact same static value of the variable?

+4
source share
2 answers

, . , , BroadcastReceiver, ContentProvider Activity , , . , AndroidManisfest (, android: process = "string" http://developer.android.com/guide/topics/manifest/receiver-element.html)

+4

Android , . . , , Activity A , Activity B . A B . , . , , . , .

ContentProvider, Android , .

0

Source: https://habr.com/ru/post/1617169/


All Articles