簡體   English   中英

retrofit 從 android 工作室的本地存儲中獲取數據

[英]retrofit fetching data from local storage in android studio

I need to save last api results in my app if the user open the app without network connection, then he will see last data fethed from the server, i need to fetch json as string and parse json to objects from string by using retrofit library in android工作室

參考: https://medium.com/@prabuddafernando_53470/mvvm-architecture-viewmodel-and-livedata-f28c0d20300b

你可以做的是檢查存儲庫上的互聯網,它沒有連接從本地共享首選項中獲取數據,如果它的數據太多使用房間持久性數據庫來保存數據。 在存儲庫中可以調用兩種方式的選項 1. 來自遠程存儲庫 2. 來自遠程存儲庫。 因此,如果互聯網不可用,您可以從本地倉庫獲取數據。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM