I have used shared preference for session maintaining in my application. And storing userId and password in Shared preference .
How to clear these data when I exit from my application. Because when I restart my application It will give the previous session.
When I log out in my application and again start app it will work nicely. In logout I have made the shared preference data (userId and password) as null. but I want to clear all these data in application exit.
I have also used below permission in manifest file: “android.permission.CLEAR_APP_USER_DATA”
<uses-permission android:name="android.permission.CLEAR_APP_USER_DATA"></uses-permission>
But I dont know how to use them in coding.
Do not do that. Use static data members for “session” data and use shared preferences for persistent data.
There is no concept of exiting an application in Android any more than there is a concept of exiting an application on the Web.
If you use static data members for your session data, the data will automatically be cleared when Android terminates the process, which it will do as a matter of course when the application has been abandoned for a significant period of time.