简体   繁体   中英

Is it possible to read/edit shared preferences in native code?

I have an Android app that includes a C library using NDK to execute some some code. Within the C library I would like to update the applications shared preferences. My question... is it possible to read/edit shared preferences in native code?

You can do anything you want in native code. It's just cumbersome - you need the JNIEnv object to first find the class ID, then the method ID, if you have any non-primitive types, you need to create those too. But then you just call the method, and you're done.

JNI Docs - look for FindClass , GetMethodId , CallVoidMethod , etc.

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