The "standard Android program" that you run does not have access to / data / data / mypackage and therefore cannot load images that you save there.
Try saving images to a directory on the SD card:
File sdDir = new File(Enviroment.getExternalStorageDirectory(), "mydirname");
If your device does not have an SD card, you need to create a public subdirectory in your package directory, and then create a readable file in it (Android 2.3 +)
File filesysDir = getDir("mydirname", MODE_WORLD_READABLE); File file = new File(sdDir, "myfile.txt"); file.setReadable(true, false); FileOutputStream fos = new FileOutputStream(file); String txt = "hello world"; fos.write(txt.getBytes()); fos.close();
Or, if you are using earlier versions of Android, it looks like you are not getting much choice in the directory name. The following code will create a globally readable file in the data / data / mypackagename / files / directory directory
FileOutputStream fos = openFileOutput("myfile2.txt", MODE_WORLD_READABLE); String txt = "hello world"; fos.write(txt.getBytes()); fos.close();
source share