I'm trying to replace an image in the internal storage of the phone with another. But i've an error with the path.That's the code:
private String saveToInternalSorage(Bitmap bitmapImage)
{
ContextWrapper cw = new ContextWrapper(getApplicationContext());
// path to /data/data/yourapp/app_data/imageDir
File directory = cw.getDir("data/data/com.aviary.android.sample/files/cdsv2/mypackage/pack_content/original-bolt-medium.png", Context.MODE_PRIVATE);
// Create imageDir
File mypath=new File(directory,"original-bolt-medium.png");
FileOutputStream fos = null;
try {
fos = new FileOutputStream(mypath);
// Use the compress method on the BitMap object to write image to the OutputStream
bitmapImage.compress(Bitmap.CompressFormat.PNG, 100, fos);
fos.close();
} catch (Exception e) {
e.printStackTrace();
}
return directory.getAbsolutePath();
}
That's the error:
12-12 16:46:43.703: E/AndroidRuntime(19190): FATAL EXCEPTION: main
12-12 16:46:43.703: E/AndroidRuntime(19190): Process: com.aviary.android.sample, PID: 19190
12-12 16:46:43.703: E/AndroidRuntime(19190): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.aviary.android.sample/com.aviary.android.sample.MainActivity}: java.lang.IllegalArgumentException: File app_file: /data/data/com.aviary.android.sample/files/cdsv2/com.aviary.sticker.53d185cc6b76fe302f001cde/pack_content/original-bolt-medium.png contains a path separator