My Android project need share a List<Right> rights
between Activities. The value of this list is initiated in LoginActivity. In other Activity, i use this list to check right of user (if user has a correspondence right, app will show correspondence tab or do something else). The problem i meet is how to store List<Right> rights
in my Android application. I have read many Post and people use Gson and Flexjson to change this list to String and use SharedPreferences.Editor putString (String key,String value)
to store in SharedPreferences. In other Activity, use preferences.getString("girl_heart_key", "DEFAULT");
to get String and Deserialize it to List<Right> rights
. But i think we can use a global static variable:
public static List<RightObject>rights = new ArrayList<RightObject>();
to share List<RightObject>rights
between Activities.
My question is: can we use global static variable to replace SharePrefrence in this case? and Is there any risk( about performance, security or memory) ?