My app will read and write .db and .txt files in a directory in Downloads.
I already select and request that folder access permission like this:
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
startActivityForResult(intent, REQUEST_CODE_FOR_DIR);
It works fine if the directory is empty and create those files from app.
If I want to read or edit those files already exist will cause error:
W/System.err: java.io.FileNotFoundException: /storage/emulated/0/Download/app_Folder/test.txt: open failed: EACCES (Permission denied)
I'm trying not to ask ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION.
How to let my app access those already exist files without using file selector?
I am trying to copy the file from /storage/emulated/0/test.txt to /cache/SH_DIR/ via android user application ,
getting error like below
java.io.FileNotFoundException: /cache/test/test.txt: open failed: EACCES (Permission denied)
When I have created as system application like , Included Application code as past of AOSP then able to copy the file to /cache/SH_DIR/ location.
May I need to add anything in the SEpolicy to copy file to /cacahe/SH_DIR/ from user application.
Can you please help me , Thanks in advance
Caused by: java.io.FileNotFoundException: /RecordsKeeper/address/src/main/res/config.properties: open failed: ENOENT (No such file or directory)
I am getting the above error while I run my application. I am not able to load my config.properties file from config.java while I'm running my android application. Although it gets loaded and works fine when I run my library test cases using that config file.
in my app I need to save some files in the device, to save the file I use:
Environment.getExternalStorageDirectory().getAbsolutePath() + "mypath"
to get the path. This work on almost all the devices but I have some problems in other devices (nexus4 for example..)
the error is:
java.lang.RuntimeException: java.io.FileNotFoundException:
/mnt/sdcard/musicfall/data/cache/.first_activation: open failed: ENOENT
(No such file or directory)
The strange thing is that it works on many device, and for this reason I can't see the problem.
PS: in "mypath" I use mkdir to create the folders that I need
I'm trying to enable my widget in my app on the Android 4.2 lockscreen and it works fine, however it is unable to resolve any of the image uris. The error I get is this:
java.io.FileNotFoundException: /storage/emulated/0/Android/data/com.tvshowfavs/cache/22kifo7sdmyet7x7kphdgch69: open failed: EACCES (Permission denied)
at libcore.io.IoBridge.open(IoBridge.java:416)
at java.io.FileInputStream.<init>(FileInputStream.java:78)
at java.io.FileInputStream.<init>(FileInputStream.java:105)
at android.content.ContentResolver.openInputStream(ContentResolver.java:447)
at android.widget.ImageView.resolveUri(ImageView.java:636)
at android.widget.ImageView.setImageURI(ImageView.java:381)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at android.widget.RemoteViews$ReflectionAction.apply(RemoteViews.java:1146)
at android.widget.RemoteViews.performApply(RemoteViews.java:2304)
at android.widget.RemoteViews.apply(RemoteViews.java:2263)
at android.widget.RemoteViewsAdapter$RemoteViewsFrameLayout.onRemoteViewsLoaded(RemoteViewsAdapter.java:286)
at android.widget.RemoteViewsAdapter$RemoteViewsFrameLayoutRefSet.notifyOnRemoteViewsLoaded(RemoteViewsAdapter.java:335)
at android.widget.RemoteViewsAdapter$4.run(RemoteViewsAdapter.java:993)
at android.os.Handler.handleCallback(Handler.java:725)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.os.HandlerThread.run(HandlerThread.java:60)
Caused by: libcore.io.ErrnoException: open failed: EACCES (Permission denied)
at libcore.io.Posix.open(Native Method)
at libcore.io.BlockGuardOs.open(BlockGuardOs.java:110)
at libcore.io.IoBridge.open(IoBridge.java:400)
Anyone have any idea why it can't open an image that is stored on the emulated storage? This image was previously downloaded and cached using the Environment.getExternalStorageDirectory(), so it should be properly written to the storage directory. This is on a Nexus 10 that I'm receiving this exception when any of the images are attempted to be loaded. Any help is appreciated.
Alright, I figured out the problem. I was using the RemoteView method setImageUri(), which it looks as though won't work since the different process can't access the file. The solution is to use setImageViewBitmap() and to decode the bitmap yourself, like this, for example: BitmapFactory.decodeFile(Uri.parse(uri).getPath())
I find it strange that the setImageUri() works fine with launchers but not on the lockscreen, however.
Tomáš was right; using a content: Uri instead of a file: Uri fixed the problem for me.
See this sample project demonstrating how to serve Files via a ContentProvider from this SO answer.