Share simple data between Android processes

Source: Internet
Author: User


We know that in Android, the easiest way to save simple data is to use sharedpreferences, however, although sharedpreferences can be set up to share data between processes, it is not reliable (and, more deadly, Different levels of application cannot be shared using sharedpreferences, for example, a normal app cannot read sharedpreferences data from a system application.

How is it possible to share data across processes with simple data, and Settings.system can easily share it across processes, and it's simple to use:

Adding custom data to the System configuration table

Settings.System.putInt (Context.getcontentresolver (), "Ipcsharedtest", 100);

Other applications read the System Configuration Table "Ipcsharedtest" key value data

Settings.System.getInt (Context.getcontentresolver (), "ipcsharedtest");


As can be seen from the above method, its configuration/fetch data are obtained from ContentProvider, and ContentProvider is natural thread-safe, so use the above method to share data between different processes, without regard to thread synchronization issues.




This article is from the "whatever957" blog, make sure to keep this source http://whatever957.blog.51cto.com/6835003/1858282

Share simple data between Android processes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.