aspose file tools*
The moose likes Android and the fly likes Set and get Cookie in android Application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Mobile » Android
Bookmark "Set and get Cookie in android Application" Watch "Set and get Cookie in android Application" New topic
Author

Set and get Cookie in android Application

Satchidananda Mohanty
Ranch Hand

Joined: Mar 12, 2008
Posts: 77

Hi guys,


After wondering a lot I am not able to find the proper solution to set and get the cookies in an android application.
Kindly share your idea with some sample source code for the same. Any help would be greatly appreciated .

Thanks,


Zeet

SCJP 6.0
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
The HttpClient library- which is part of the Android API- can do that.
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6657
    
    5

A cookie is just another HTTP header. You can always set it while making a HTTP call with the apache library or with HTTPUrlConnection. Either way you should be able to read and set HTTP cookies in this fashion.

More on making HTTP calls from android here -> http://android-developers.blogspot.in/2011/09/androids-http-clients.html

SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
Satchidananda Mohanty
Ranch Hand

Joined: Mar 12, 2008
Posts: 77

Hello,

I want to set some variables to my application and which will be accessible all over the application. Just like session management in J2EE.
And gone through the above details and I do not have any url to set inside the code . If I'm wrong could you please post some sample codes for the same.

Thanks,
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
So there's no HTTP involved at all? That means there'll be no cookie. For shared in-memory storage you may want to look into using an Applictaion class - http://www.google.de/search?q=android.app.Application
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Set and get Cookie in android Application
 
Similar Threads
Mapview
New to Android Development, Installation Problem
Are there specific frameworks to use with Android?
Can't Install Android platforms on Android SDK
problem in installing android sdk in eclipse