androidGuy
androidGuy

Reputation: 5643

Does static variable retains value even when android application is closed

I am developing an android application using bluetooth. When I launch my application for first time, my application works well, but when I exit the application and run it once again I get problems with bluetooth connectivity.

I am not able to establish connection with another device.I am using few critical static variables. My doubt is does these static variables retains the value even when application is exited.

Also i notice that my application is still running i mean its not stopped. Should we stop the application explicitly when we exit? If so ,how to do that. I am simply using finish when i exit the application.

Upvotes: 3

Views: 1616

Answers (2)

mehul9595
mehul9595

Reputation: 1955

yes, static variable will be still in its memory. You can check upon your exit of app, clear out all the static fields declared

Upvotes: 1

Sunil Pandey
Sunil Pandey

Reputation: 7102

yaa it will retain value. because application once started does not get killed immediately. but you can not rely on this, because some time android os may kill long inactive processes to release memory. in this case you can loose your data.

Upvotes: 3

Related Questions