简体   繁体   中英

Shared Pref Data in App1 should fetch the latest data I,ve stored in other App?

I have two apps, App1 and App2. I,m saving some data in App2 and accessing in App1. So when i,m coming back to App1 from App2 using backpress, shared pref data will not refresh that i,m accessing from App2. On removing App1 from background and coming back to same page will do the work.

So, what should I do such that, Shared Pref Data in App1 will fetch the latest data I,ve stored in App2 ?

将数据写入共享首选项时,请使用edit.apply()而不是edit.commit(),因为edit.apply将立即更新首选项对象,并异步保存新值,从而使您可以读取最新值。

你无法改变的其他sharePreference数据,你可以使用ContentProviders这些都是应用程序之间共享数据的好方法,而应用程序中,你可以轻松地访问存储数据(sharePreference的)从获得更详细此链接

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM