I have dat file, which is binary file.It currently inside raw folder on my project. I want to use the file in my program. I want to copy it to certain location on the device but when executing the method, I am getting the error "Failed to read Data Meta Data"
Here is the method:
public void copyRawOnSdCard(){
File sdcard = Environment.getExternalStorageDirectory();
String targetPath = sdcard.getAbsolutePath() + File.separator + "shape_predictor_68_face_landmarks.dat";
File file = new File(targetPath);
if (!file.exists())
{
final ProgressDialog pd; pd = ProgressDialog.show(this, "Copy Files for the First Time", "Please wait",
true);
pd.show();
InputStream in = getResources().openRawResource(
getResources().getIdentifier("shape_predictor_68_face_landmarks",
"raw", getPackageName()));
FileOutputStream out = null;
try {
out = new FileOutputStream(targetPath);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
byte[] buff = new byte[1024];
int read = 0;
try {
while ((read = in.read(buff)) > 0) {
out.write(buff, 0, read);
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try{
in.close();
}catch (IOException e) {
e.printStackTrace();
}
try {
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}
pd.cancel();
}
}
Ideas? Thanks