Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Android™ Development

Reply
Retired
Posts: 140
Registered: ‎04-19-2013
My Device: BlackBerry Z10

Re: Permission denied when trying to create a file in the cash folder

[ Edited ]

Ah, I just noticed this ... Are you perhaps not using getExternalCacheDir() in some spots? Smiley Happy

 

I say this because here's the implementation

 

    public File getExternalCacheDir() {
        synchronized (mSync) {
            if (mExternalCacheDir == null) {
                mExternalCacheDir = Environment.getExternalStorageAppCacheDirectory(
                        getPackageName());
            }

            ...

    }

 

    public static File getExternalStorageAppCacheDirectory(String packageName) {
        return new File(new File(EXTERNAL_STORAGE_ANDROID_DATA_DIRECTORY,
                packageName), "cache");
    }

 

    private static final File EXTERNAL_STORAGE_ANDROID_DATA_DIRECTORY
            = new File (new File(getDirectory("EXTERNAL_STORAGE", "/sdcard"),
                    "Android"), "data");

 

That stack trace where it showed permission denied doesn't even have a directory structure that includes the "cache" directory.  The expected structure should be /<EXTERNAL_STORAGE>/Android/data/<pkg>/cache.

 

Edit: And now I'm just noticing there's two posters with two different issues here.  Doh!  Well hopefully this helps someone.

Contributor
Posts: 19
Registered: ‎04-03-2013
My Device: Z10
My Carrier: Reliance India

Re: Permission denied when trying to create a file in the cash folder

Hi,

 

I am talking about SignEasy here. We see the error when writing to internal storage directory of the App, not the cache.

 

For example:

/data/data/com.glykka.easysign/files/[email_address_of_SignEasy_user]/orig_docs/Mutual_NDA.pdf (Permission denied)

 

We use getFilesDir() to get the root of App specific internal storage directory and then append the path with email address of SignEasy user followed by a sub folder "orig_docs" as shown above.

 

Once the file writing fails to the above directory, even reading any existing file from the above directory fails with the same exception.

Contributor
Posts: 19
Registered: ‎04-03-2013
My Device: Z10
My Carrier: Reliance India

Re: Permission denied when trying to create a file in the cash folder

Here is the link to SignEasy-free app:  http://appworld.blackberry.com/webstore/content/22626873

 

Please let me know if you see the error, as it happens randomly to different users. Even if it succeeds the first time,

it may fail on subsequent file import / download attempts.

 

Thanks,

Sunil

Contributor
Posts: 19
Registered: ‎04-03-2013
My Device: Z10
My Carrier: Reliance India

Re: Permission denied when trying to create a file in the cash folder

Justin and Bradley,

 

I noticed that the bug https://www.blackberry.com/jira/browse/BBTEN-1135 has been resolved as "Cannot Reproduce".  It is clearly not true.

 

Please watch the video below on SignEasy App failing to download the file.

 

http://dl.dropboxusercontent.com/u/548071/BB10-file-download-error.m4v

 

I appreciate someone from your team getting in touch with me directly for help in reproducing the issue or

suggest a temporary workaround to fix it.

 

Thanks

Sunil

Retired
Posts: 140
Registered: ‎04-19-2013
My Device: BlackBerry Z10

Re: Permission denied when trying to create a file in the cash folder

[ Edited ]

Perhaps it got resolved in 10.1 and that's why it was marked not reproducible?

 

It's going to be hard to tell why it's failing without being able to look at the directory structure.

 

Edit: To clarify, you're able to create new folders in your cache directory or no?  Or does it require an uninstall / install to correct the issue?

Contributor
Posts: 19
Registered: ‎04-03-2013
My Device: Z10
My Carrier: Reliance India

Re: Permission denied when trying to create a file in the cash folder

Hi Bradley,

 

Our issue is not related to the cache folder. We are trying to save a file in the internal app storage directory.

 

We maintain two different folders in the app's internal sandbox storage for saving original vs. signed documents.

 

Original documents:

/data/data/com.glykka.easysign/files/[email_address_of_SignEasy_user]/orig_docs

 

Signed documents:

/data/data/com.glykka.easysign/files/[email_address_of_SignEasy_user]/signed_docs

 

As an example, if my SignEasy account is: abc@foo.com, the original document's folder path is: /data/data/com.glykka.easysign/files/abc@foo.com/orig_docs

 

The weird thing is that downloading a signed document never fails , but in case of original documents, we get the following exception frequently (Not always) below.

 

04-17 08:34:57.945: W/System.err(87867610): java.io.IOException: Permission denied
04-17 08:34:57.947: W/System.err(87867610):     at java.io.File.createNewFileImpl(Native Method)
04-17 08:34:57.948: W/System.err(87867610):     at java.io.File.createNewFile(File.java:1257)
04-17 08:34:57.948: W/System.err(87867610):     at com.glykka.easysign.util.EasySignUtil.saveFile(EasySignUtil.java:380)
04-17 08:34:57.948: W/System.err(87867610):     at com.glykka.easysign.SignDocument$SyncDocument.handleFileDownload(SignDocument.java:1492)
04-17 08:34:57.948: W/System.err(87867610):     at com.glykka.easysign.SignDocument$SyncDocument.doInBackground(SignDocument.java:1338)
04-17 08:34:57.948: W/System.err(87867610):     at com.glykka.easysign.SignDocument$SyncDocument.doInBackground(SignDocument.java:1)
04-17 08:34:57.948: W/System.err(87867610):     at android.os.AsyncTask$2.call(AsyncTask.java:185)
04-17 08:34:57.948: W/System.err(87867610):     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306)
04-17 08:34:57.948: W/System.err(87867610):     at java.util.concurrent.FutureTask.run(FutureTask.java:138)
04-17 08:34:57.948: W/System.err(87867610):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
04-17 08:34:57.948: W/System.err(87867610):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
04-17 08:34:57.948: W/System.err(87867610):     at java.lang.Thread.run(Thread.java:1019)

There is no definite pattern to reproduce the issue, sometimes we get the error in any of the following scenarios.

 

- fresh install, first attempt to download an original file

- fresh install, first original file download works, 2nd one and other attempts fail

- fresh install, first original file download works, reboot the device, launch the app, try to download another file, it fails.

 

Can I show it to you using BBM screensharing? My PIN is: 24DA161B.

 

Thanks

Sunil

Retired
Posts: 140
Registered: ‎04-19-2013
My Device: BlackBerry Z10

Re: Permission denied when trying to create a file in the cash folder

[ Edited ]

Sorry, I mean files directory, not cache directory.  But my thought process remains the same.

 

I want to know if you can access other files in that folder.  Or if everything in that folder is permission denied.

Contributor
Posts: 19
Registered: ‎04-03-2013
My Device: Z10
My Carrier: Reliance India

Re: Permission denied when trying to create a file in the cash folder

Once the exception happens, the app cannot access/read the existing files or write any more files in that directory: "orig_docs".

 

But the "signed_docs" directory is fully accessible.

 

-Sunil

Retired
Posts: 140
Registered: ‎04-19-2013
My Device: BlackBerry Z10

Re: Permission denied when trying to create a file in the cash folder

File has the following APIs

 

canRead()

canWrite()

canExecute()

 

You'll have to modify your app to do this, but I'd like to know the output of those 3 methods for key folders.

 

/data/data/com.glykka.easysign/files/<user>/orig_docs

/data/data/com.glykka.easysign/files/<user>/signed_docs

 

Might give a hint as to why you can't access it.  Since you say you can access signed_docs always and it's orig_docs giving you the issue I'm going to assume the parent directories would all return true, but you can check those as well.

Contributor
Posts: 19
Registered: ‎04-03-2013
My Device: Z10
My Carrier: Reliance India

Re: Permission denied when trying to create a file in the cash folder

Bradley,

 

I will check that and upload a new build just for testing.

 

Thanks

Sunil