public class MYApplication extends Application {
String property;
setter getter
}
does above code make sure property will not be collectied by android OS if not used for a long period of time.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No. Android reserves the right to kill any application at any time if it feels the need. Even foreground processes can be killed if the device gets low on memory. This means the
Applicationobject will be destroyed and all its attributes lost.The only way to ensure your application’s transient state never gets lost is to respond appropriately to the lifecycle events Android offers, or just store values persistently.
If you want to store a
Stringfor your application why not use Preferences? This means the value would be never be lost, even if the device is switched off.(I’m not quite sure what
getterandsetterare in your code sample, but I don’t think that’s relevant.)