Search code examples
androidauthenticationcredentialsntlm

How to set credential persistence permanent on Android


My app has save login credential feature, so I store cookies for the next use after succeeding to sign in. However, after a time period, the session will be time out and cannot log in with the cookies any more. On iOS, after setting credential persistence to permanent, the app works nicely even after restarting the phone:

[[challenge sender] useCredential:[NSURLCredential credentialWithUser:username password:password persistence:NSURLCredentialPersistencePermanent] forAuthenticationChallenge:challenge];

On Android, I cannot find out such kind of this option. Here is from my HttpHelper class:

((AbstractHttpClient) HttpHelper.client).getAuthSchemes().register("ntlm",new NTLMSchemeFactory());
  NTCredentials creds = new NTCredentials(user, pass, "", domain);
  ((AbstractHttpClient) HttpHelper.client).getCredentialsProvider().setCredentials(AuthScope.ANY, creds);

The server is SharePoint so I have to deal with ntlm authentication by following this instruction

If you have idea, please let me know.

Thank you.


Solution

  • Consider using Sharedpreferences provided by the Android framework.