Giter Club home page Giter Club logo

Comments (5)

apsun avatar apsun commented on May 31, 2024

Unfortunately, RemotePreferences does not support this. The main reason is that RemotePreferences aims to be fully API compatible with SharedPreferences, and SharedPreferences has OnSharedPreferenceChangeListener which can't be implemented through the ContentProvider API without knowing upfront the complete set of preferences to listen for.

If you want a 2-level deep preference tree, I would recommend encoding it in the key instead (like, change getSharedPreferences("foo").getString("bar") to getSharedPreferences("all").getString(foo:bar") or something like that).

from remotepreferences.

Dr-TSNG avatar Dr-TSNG commented on May 31, 2024

Oh, that's so bad. Since my app has complex preference structure, encoding in the key seems so troublesome. In fact, I just want package "android" to read the preferences from my Xposed module (no need for write), without using "new XSharedPreferences" from API 93. Is there any solution?

from remotepreferences.

apsun avatar apsun commented on May 31, 2024

I don't see why it's so hard? Just define a function to transform the file name and key into a single string, and use that everywhere. Alternatively, use the filename as the key, and store the value as a JSON object encoded into a string (which sounds appropriate anyways if you truly have "complex preference structure").

It's unlikely that RemotePreferences will ever support variable file names, as it adds a lot of complexity on our end, or breaking backwards compatibility, or both, for little benefit (imo, unless you can convince me otherwise). Sorry.

from remotepreferences.

Dr-TSNG avatar Dr-TSNG commented on May 31, 2024

Yes you are right, storing the values as json is a perfect solution, thanks.

from remotepreferences.

Android1500 avatar Android1500 commented on May 31, 2024

Yes you are right, storing the values as json is a perfect solution, thanks.

You can use target sdk 23 and and use MODE_WORDLD_READABLE

from remotepreferences.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.