The simple answer is you can't. The loadlibrary implementation requires a file from the file-system. Normally all the ABI matching lib folder is extracted when the APK file is installed so all libraries are present in file-system and can be directly loaded.
Therefore you have to save the context to a file in file-system and then load this file using System.loadLibrary
.
The only exception are libraries of apps that have the AndroidManifest.xml setting android:extractNativeLibs=false
. In that case the libraries from lib/(arm64-v8a|x86|etc.)
are stored without compression in the APK and aligned to 4K pages so that these libraries can directly be loaded from within the APK (the APK file is loaded as regular file and then starting from a certain offset the library data can be directly loaded without so this way totally ignores that the library is inside a ZIP file). But again you can't specify the path within the APK so that this is no help in your situation.