由于在apk的安装过程中assets中的文件并没有从apk包中解压出来,所以在JNI的C++代码中不能按照原始的路径直接进行访问,一种常用的方法为将assets中的文件复制到sdcard的目录下,然后传递绝对路径给JNI中的C++代码中进行访问。
/**
* copy the files and folders of assets to sdCard to ensure that we can read files in JNI part
* @author Qinghao Hu
* @date 2015/9/22
* @version 1.0
* @email qinghao.hu@nlpr.ia.ac.cn
*/
package com.hqh.utils;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
import android.content.Context;
import android.content.res.AssetManager;
import android.util.Log;
public class AssetCopyer {
private static String TAG="AssetCopyer";
/**
* copy all the files and fo