Amit Hooda
Amit Hooda

Reputation: 2144

Android NDK shared variable between java and C

In NDK i know how to pass parameters from Java to C and then return values from C to Java.

But can we have some array which i can access from both Java and C simultaneously. Means i can add values in that array from C and after adding one value or 3-4 values i can access those values from Java?

If this is not feasible can we have something else using which i can get those values simultaneously?

Upvotes: 0

Views: 855

Answers (1)

Nikolay Elenkov
Nikolay Elenkov

Reputation: 52946

Put array, etc. in the Java code and use JNI to access it from native code (JNI goes both ways). Needless to say, you need to be careful. BTW, you can't really 'add values' to an array in Java. If you really mean 'add' and not 'store', you might need a list or another dynamic structure.

Upvotes: 2

Related Questions