[英]I want to store the Cookie permanently in my Android App after the app restart to use the cookie for rest api call (HttpUrlConnection)
I have used '''CookieManager cookieManager = new CookieManager();我用过'''CookieManager cookieManager = new CookieManager(); CookieHandler.setDefault(cookieManager);''' CookieHandler.setDefault(cookieManager);'''
It is working fine but when the app restart the cookie gets deleted and i cant used it for further rest calls.它工作正常,但是当应用程序重新启动时,cookie 被删除,我无法将其用于进一步的 rest 调用。
There are multiple ways using which you can save data permanently (until you can'y clear app data).您可以通过多种方式永久保存数据(直到您可以清除应用数据)。
Using above listed methods you can store you data and also get those data after restart of application/mobile phone.使用上面列出的方法,您可以存储数据并在重新启动应用程序/手机后获取这些数据。
You can get an idea of access of above listed methods using below links.您可以使用以下链接了解上述方法的访问方式。
SharedPreference: https://www.tutorialspoint.com/android/android_shared_preferences.htm SharedPreference: https://www.tutorialspoint.com/android/android_shared_preferences.htm
SQLite: https://www.geeksforgeeks.org/how-to-create-and-add-data-to-sqlite-database-in-android/ SQLite: https://www.geeksforgeeks.org/how-to-create-and-add-data-to-sqlite-database-in-android/
Room: https://www.geeksforgeeks.org/how-to-perform-crud-operations-in-room-database-in-android/房间: https://www.geeksforgeeks.org/how-to-perform-crud-operations-in-room-database-in-android/
Thank you.谢谢你。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.