Android Internal Memory Read File
I have a problem with Android internal storage. I created a folder in the root folder of the package calling getDir()
and MODE_WORLD_WRITEABLE
because I want the camera application to record the captured image to that folder. Anyway, I can see that the captured image is inside this folder with DDMS
. The problem is, I cannot read this file.
I tried to read the 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 there is only the second message in LogCat (can't read).
I also tried to create FileInputStream
with filename, but I get FileNotFoundException
.
Can someone tell me what I am doing wrong here?
Thank you in advance
EDIT:
The read file is correct, but the only problem is that when the camera app saves the image to the specified location, the resolution set by the cam app for the image file, -rwxrwx---.
After changing the permissions from
adb (chmod 777 image.jpeg)
I was able to read the image. Interestingly, the Cam app writes image files sdcard
to using ----rwxr-x
.
Is there a way to change the resolution of a file at runtime?
source to share
Why not put it in your default photo directory?
File path = Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_PICTURES);
File file = new File(path, "DemoPicture.jpg");
(From: http://developer.android.com/reference/android/os/Environment.html )
See also a more complete example of calling a camera app: http://developer.android.com/training/camera/photobasics.html
source to share
When reaching out to Android developers , you have to use openFileOutput()
and openFileInput()
to work in internal storage ... you are prohibited / unable to do there. Android does it itself. This data will be deleted when your app is uninstalled.
source to share