Reputation: 8729
I have a json file. So, I was parsed the json file and I want to share jsonarray.length()
value all the classes in application. So, what is recommended way to do that??
Upvotes: 2
Views: 96
Reputation: 8641
Upvotes: 1
Reputation: 706
You can also use Application class (http://developer.android.com/reference/android/app/Application.html) and store the info you need in a field; anyway I think the best solutions have already been suggested :)
Upvotes: 2
Reputation: 68715
Three options:
First one is to store it in a private static variable and expose a method to share it with others.
Second one is to expose it as a public static variable
Third one is to store in SharedPreference
Upvotes: 1
Reputation: 54672
Option 1: you can set it public static
Option 2: you can store it in a SharePreference
Upvotes: 5