0

I have an Android application with following components: 1) An activity 2) A service 3) A public class with static field.

public class SharedData{
    static ArrayList<String> backup = new ArrayList<String>();
}

My understanding is that whenever activity or service is launched for the first time, ArrayList would be initialized.

Here are my questions:

1) When would ArrayList be initialized again? The activity and/or service may start and stop depending on their visibility and Android system resource manager.

2) ArrayList would be modified by both activity and service. Is this going to cause any issues? I have read recommendations about using a class that extends Application. What is the drawback of above approach?

kmaini
  • 164
  • 5
  • The question linked as duplicate to this question does not answer the two questions mentioned above especially question 1). The scenario presented here is more complex and needs clarification. I have already read the answer provided to the "duplicate" question referenced above and found that it is not a duplicate. – kmaini Sep 24 '15 at 19:21
  • Since the duplicate linked above already has good information on this topic, I will just post my specific question as a comment there. – kmaini Sep 24 '15 at 19:25

0 Answers0