public class AssetCopyHelper {
static {
System.loadLibrary("asset_copy");
}
public native void copyAssetToDirectory(String assetName, String destPath);
}
c++实现:
#include <jni.h>
#include <android/asset_manager.h>
#include <android/log.h>
#include <stdio.h>
#include <stdlib.h>
#define LOG_TAG "AssetCopyHelper"
#define LOGI(fmt, ...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, fmt, ##__VA_ARGS__)
#define LOGE(fmt, ...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, fmt, ##__VA_ARGS__)
JNIEXPORT void JNICALL
Java_com_example_yourapp_AssetCopyHelper_copyAssetToDirectory(JNIEnv *env, jobject obj, jstring assetName, jstring destPath) {
AAssetManager* assetManager = AAssetManager_fromJava(env, assetManagerObj);
const char* nativeAssetName = env->GetStringUTFChars(assetName, 0);
const char* nativeDestPath = env->GetStringUTFChars(destPath, 0);
AAsset* asset = AAssetMa

最低0.47元/天 解锁文章
4097

被折叠的 条评论
为什么被折叠?



