Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6175129
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:52:15+00:00 2026-05-23T23:52:15+00:00

I have a HttpClient to communicate with my server, and I want to persist

  • 0

I have a HttpClient to communicate with my server, and I want to persist my session to keep user logged between Activities.

Up till now, I have used a Service to back up my HttpClient, including a background thread to do the heavy work.

Another way to do this I know through my googling is that save the Cookie in a local file/xml/database, and check if it exists, if it exists, then use it in the new HttpClient I created each Activity.

Which way is better or are there even better ways to achieve what I want?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T23:52:16+00:00Added an answer on May 23, 2026 at 11:52 pm

    I personally would go with the cookie. Cookies are commonly used to do just this. HttpClient accepts a CookieStore that you can have backed by a file. When the cookie is updated, just update the file and when it has to be retrieved either use an in memory copy or read the file. I don’t know how your would back up your session with just a service. The Service would have to save some state somewhere. Serializing an HttpClient does not seem to be possible. So I would just implement a CookieStore.

    CookieStore

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to use the jetty httpclient (in netbeans) but have the least number
I have a Java client that uses HttpClient to connect to a server and
Any examples, tips, guidance for the following scenario? I have used Apache HttpClient to
I have a class for Httpclient. The same instance is used throughout the application.
I have used the following code on my client side (Android emulator). HttpClient client=new
I'm have a java program that uses Apache httpclient api. This is used to
i am try to call webservice using Android.I have used httpclient as well as
I have been trying to use the same HttpClient instance throughout different activities, but
For a while, I have been using HttpClient in a multithreaded environment. For every
I have Android pet-project DroidIn which utilizes HttpClient 4 (built into Android) to do

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.