存储和Android的恢复饼干(永久性Cookie存储) [英] Storing and restoring cookies in Android (persistent cookie storage)
问题描述
搜查了不少。
我有一个应用程序。在服务器上的应用程序登录,并收到一些饼干,那么它可以执行与他们一些POST请求(例如获取用户配置文件)。我想将它们存储会话之间(这意味着我可以重新启动设备,运行应用程序,并获得资料,而不需要额外的记录)。或者,换句话说,如何创建永久性的Cookie存储?
I have an app. App logins on server and receive some cookies, then it can execute some POST requests with them (e.g. to get user profile). I want to store them between sessions (it means I can restart a device, run app and get profile without extra logging in). Or, in other words, how to create persistent cookie storage?
我使用的唯一DefaultHttpClient,没有网页视图。不过,我应该用一些饼干创建后初始化此客户端。我应该把它保存在文件还是什么?有没有办法做到这一点iOS中没有这样怪异的黑客,在文件中存储/ DB和手动灌装CookieManagers?
I'm using the only DefaultHttpClient and there are no WebViews. But I should initialize this client after creation with some cookies. I should store it in file or what? Are there ways to do it in iOS way without weird hacks, storing in files/DBs and manual filling CookieManagers?
推荐答案
现在我使用的是 PersistentCookieStorage 类为这些目的。我创建当应用程序被启动了单。它存储在共享preferences饼干。
Now I'm using a PersistentCookieStorage class for those purposes. I create a singleton when the app is launched. It stores cookies in SharedPreferences.
这篇关于存储和Android的恢复饼干(永久性Cookie存储)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!