I have a lot of files (of two extensions, .ppn and .pv) in R.raw
. I'm trying moving them into internal storage.
I've tried doing this:
private static void copyPorcupineConfigFiles(Context context) {
int[] resIds = {R.raw.alexa, R.raw.americano, R.raw.avocado, R.raw.blueberry,
R.raw.bumblebee, R.raw.caterpillar, R.raw.christina, R.raw.dragonfly,
R.raw.flamingo, R.raw.francesca, R.raw.grapefruit, R.raw.grasshopper,
R.raw.iguana, R.raw.picovoice, R.raw.pineapple, R.raw.porcupine,
R.raw.raspberry, R.raw.terminator, R.raw.vancouver, R.raw.params};
Resources resources = context.getResources();
for (int resId : resIds) {
String filename = resources.getResourceEntryName(resId);
String fileExtension = resId == R.raw.params ? ".pv" : ".ppn";
InputStream is = null;
OutputStream os = null;
try {
is = new BufferedInputStream(resources.openRawResource(resId),
256);
os = new BufferedOutputStream(context.openFileOutput(filename + fileExtension,
Context.MODE_PRIVATE), 256);
int r;
while ((r = is.read()) != -1) {
os.write(r);
}
os.flush();
} catch (IOException e) {
showErrorToast(context);
} finally {
try {
if (is != null) {
is.close();
}
if (os != null) {
os.close();
}
} catch (IOException e) {
showErrorToast(context);
}
}
}
}
It should save in data/0/com.package.name
When I do:
String keywordFilePath = new File(this.getFilesDir(), ".ppn")
.getAbsolutePath();
String modelFilePath = new File(this.getFilesDir(), "params.pv").getAbsolutePath();
It gives me the path:
/data/user/0/com.package.name/files/alexa.ppn
However, when I look with File Manager or try retrieving the file programatically, it's not there.