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
New Contributor
Posts: 2
Registered: ‎02-21-2014
My Device: curve 8900

help with "Destination must be on external storage"

hi, i'm trying to make a port of my android app, but i get this error.

 

java.lang.SecurityException: Destination must be on external storage: file:///mnt/sdcard/Android/data/com.phoenix986.quiz/files/Download/vfp2014
at android.os.Parcel.readException(Parcel.java:1425)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:185)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:137)
at android.content.ContentProviderProxy.insert(ContentProviderNative.java:420)
at android.content.ContentResolver.insert(ContentResolver.java:866)
at android.app.DownloadManager.enqueue(DownloadManager.java:911)
at com.phoenix.quiz.StartFragment$6.onClick(StartFragment.java:859)
at android.view.View.performClick(View.java:4204)
at android.view.View$PerformClick.run(View.java:17373)
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.app.ActivityThread.main(ActivityThread.java:5056)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:840)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:607)
at dalvik.system.NativeStart.main(NativeStart.java)

 

this is the code:

request.setDestinationInExternalFilesDir(activity,Environment.DIRECTORY_DOWNLOADS,testid);
					 

 

these are the permission i have in the manifest:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.DOWNLOAD_WITHOUT_NOTIFICATION" />
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />

 

anyone can help me?

 

ps. i'm trying the code on the bb10 device simulator

New Contributor
Posts: 2
Registered: ‎02-21-2014
My Device: curve 8900

Re: help with "Destination must be on external storage"

UP..

Retired
Posts: 264
Registered: ‎01-08-2013
My Device: BlackBerry 10 Dev Alpha B
My Carrier: Bell

Re: help with "Destination must be on external storage"

Hey Phoenix986,

 

What does the .WRN file say?

Justin Jasmann | Android Application Development Consultant
Developer Relations
developer.blackberry.com
Trusted Contributor
Posts: 160
Registered: ‎11-17-2010
My Device: PlayBook, Z10, Q10

Re: help with "Destination must be on external storage"

Hi,

 

I think you have referred your path in a non-standard way (/mnt/sdcard).

 

You could try to use the Environment.getExternalStoragePublicDirectory to get the sdcard path without hardcoding it. Otherwise "/storage/sdcard" generally should work.

--
If you find this post useful please Like it.
If it solves your problem please mark as solution.
Retired
Posts: 140
Registered: ‎04-19-2013
My Device: BlackBerry Z10

Re: help with "Destination must be on external storage"

External storage on our platform is symlinked to /sdcard/external_sd

 

/mnt/sdcard links /sdcard, and /sdcard links to internal storage (as it does on many Android devices, for legacy reasons).

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

Re: help with "Destination must be on external storage"

You bring up an interesting point. /storage/sdcard isn't a "thing" on BB10.

Also, it's not a given that /storage/sdcard exists or points to the correct spot either. Smiley Happy