How To Save Cookies In Android App?
API creating and save data in a cookie. It works well on the browser. But that cookie is not saved in the android app. Always show a blank array. Anybody know about this? Do androi
Solution 1:
You can try this.
/**
* Checks the response headers for session cookie and saves it if it
* finds it.
*
* @paramheaders
* Response Headers.
*/publicvoidcheckSessionCookie(Map<String, String> headers)
{
// Config.SET_COOKIE_KEY = "Set-Cookie"if (headers.containsKey(Config.SET_COOKIE_KEY) && headers.get(Config.SET_COOKIE_KEY).startsWith(Config.SESSION_COOKIE))
{
String cookie = headers.get(Config.SET_COOKIE_KEY);
if (cookie.length() > 0)
{
String[] splitCookie = cookie.split(";");
String[] splitSessionId = splitCookie[0].split("=");
cookie = splitSessionId[1];
// Now here set cookie to your Preference file.
}
}
}
Solution 2:
kindly refer,
#How to store data locally in an Android app!
among this options, you can use #Shared Preferences
and store user information and access it through out the application.
Post a Comment for "How To Save Cookies In Android App?"