In my android project I have several fields that I use in several activities, so I implement this class to hold them:
public class MainApplication extends Application {
private UserId userId;
}
also I can declare the UserId as static:
public class MainApplication extends Application {
private static UserId userId;
}
what is the difference between the two implementation? and which is preferable ?
edit,
I am asking this question because: currently I am declaring the userId as non static,and i am using it in activity number one and number tow.
but sometimes I get NullPointerException in activity number two although the userId was not null in activity number one. so I thought maybe if I declare it as static it will solve the problem ? thank you