I have a problem with Android internal storage. I have created folder in package root folder calling getDir()
and with MODE_WORLD_WRITEABLE
because I want camera app to write captured image in this folder. Anyway, I can see that captured image is inside that folder with DDMS
.
Problem is that I cannot read that file.
I tried to read file with this code:
File file = context.getDir("images", Context.MODE_WORLD_READABLE);
File image = new File(file, "image.jpeg");
if (image.canRead())
Log.w("read", "can read");
else
Log.w("read", "can't read");
And in LogCat there is only second message (can't read).
I have also tried to create FileInputStream
with file name but I receive FileNotFoundException
.
Can somebody tell me what I'm doing wrong here?
Thanks in advance
EDIT:
Reading file is correct but only problem is that when cam app is saving image to specified location, permission set by cam app to image file are -rwxrwx---.
After changing permissions with
adb (chmod 777 image.jpeg)
I was able to read image. Interesting thing is that cam app is writing images files to sdcard
with ----rwxr-x
.
Is there any way to change file permission in runtime?