Unlike in C/C++ or PHP you can't have global variables in Java (or
C#).
The closest thing to a global is a public static variable.
for example
class YourActivity extends Activity {
public static boolean bMyBoolean;
}
Now you could access it with
if(YourActivity.bMyBoolean) {
// Do something
}
However be carefull not to save any objects which holds a reference to
the context of your activity, as this could cause some serious memory
leaks
It is possible to set/change the value and it's accessible from
anywhere
On Mar 28, 9:33 am, Zhubham <[email protected]> wrote:
> Hi,
>
> Can anyone hep me with how to make a (boolean) variable global in
> Android?
>
> Thanks.
>
> Best Regards,
> Zhubham
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---