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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Developer
Posts: 28
Registered: ‎11-11-2013
My Device: -
My Carrier: -
Accepted Solution

File.exists() returns false for standard Music folder

[ Edited ]

This appears really weird. For both symlink and canonical paths File.exists() returns false!

 

The following code was tested with Q10 emulator:

   

File musicFolder = 
Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_MUSIC); System.out.println(
"Path \"" + musicFolder.getPath() + "\" " + (musicFolder.exists()
? "exists " : "does not exist")); try { musicFolder = musicFolder.getCanonicalFile(); System.out.println(
"Path \"" + musicFolder.getPath() + "\" " + (musicFolder.exists()
? "exists " : "does not exist")); } catch (IOException ex) { // Should not be here }

 

Output:

Path "/mnt/sdcard/Music" does not exist
Path "/accounts/1000/shared/music" does not exist

 

A propos,  the folder exists and even has some music files in it, which are played OK.

 

 

Any comments?

 

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

Re: File.exists() returns false for standard Music folder

Yea ... in order to access anything under /sdcard, you need the 1000_shared gid.  Which you only get on our platform if you have the WRITE_EXTERNAL_STORAGE android permission.

 

On stock Android, you're granted READ_EXTERNAL_STORAGE permission implicitly (at least for now).  On ours you don't.

 

So, does your app have WRITE_EXTERNAL_STORAGE?  If not, try that.

Developer
Posts: 28
Registered: ‎11-11-2013
My Device: -
My Carrier: -

Re: File.exists() returns false for standard Music folder

Thanks a lot, it really helped.

 

It is really strange that I need WRITE_EXTERNAL_STORAGE when I don't really write to it.

 

Now I need to alter Manifest all the time, using READ_EXTERNAL_STORAGE for Android Kit-Kat compatibility and WRITE_EXTERNAL_STORAGE for Blackberry, otherwise the app will frighten Android users Smiley Happy

 

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

Re: File.exists() returns false for standard Music folder

READ_EXTERNAL_STORAGE is granted implicitly in stock JellyBean 4.2.2.  That's (somewhat) even more concerning. 

 

Perhaps it could be clearer that READ_EXTERNAL_STORAGE isn't granted implicitly on our platform, and that you need WRITE_EXTERNAL_STORAGE to grant it.  I suppose though it's better than us granting WRITE_EXTERNAL_STORAGE implcitly.

Developer
Posts: 28
Registered: ‎11-11-2013
My Device: -
My Carrier: -

Re: File.exists() returns false for standard Music folder

[ Edited ]

I hope, for forthcoming Blackberry releases (with Android 4.4+ support)  we will need only READ_EXTERNAL_STORAGE to read  files from SD card.