开发者

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

开发者 https://www.devze.com 2023-01-27 21:00 出处:网络
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 r

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号