Android Question No such file or directory. File.DirDefaultExternal not exists.

netsistemas

Active Member
Licensed User
Longtime User
I change manifest, from sdk 4 to 5 and targetsdk 14 to 26


and now the file.dirdefaultexternal is not create automatic.

File.ExternalWritable return TRUE.

Import: This effect ONLY suceded on some phones

I can not write (or read) files in this directory because is not present (not exist).
If i create this directory manual, all is ok
In this link say that this directory are create automatic, but no.

https://www.b4x.com/android/forum/threads/text-files.6690/


File.DirDefaultExternal
The default folder for your application in the SD card.
The folder is: <storage card>/Android/data/<package>/files/
It will be created if required.

But no.

This is my manifest:
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: http://www.b4x.com/forum/showthread.php?p=78136
'5.26
'4.14
AddManifestText(
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="26"/>
<supports-screens android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:anyDensity="true"/>)
AddManifestText( <permission
android:name="$PACKAGE$.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses-feature android:glEsVersion="0x00020000" android:required="true"/>)
AddApplicationText(<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="xxxxxxxxxxxxxxxxxxxxx"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
AddPermission(android.permission.WRITE_EXTERNAL_STORAGE)
AddPermission(android.permission.PROCESS_OUTGOING_CALLS)

thanks.
 
Last edited:

Mahares

Expert
Licensed User
Longtime User
and now the file.dirdefaultexternal is not create automatic.

Did you try runtime permission like this:
B4X:
Private rp As RuntimePermissions
Private FilePath as string
    If File.ExternalWritable Then FilePath = rp.GetSafeDirDefaultExternal("") Else FilePath = File.DirInternal
 
Upvote 0

netsistemas

Active Member
Licensed User
Longtime User
thanks. Perfect.


In old version (i think previous to 4.4) you can use this:
File.DirDefaultExternal and ADD permision in manifest
but,
in new versión is not necessary add permision and use rp.GetSafeDirDefaultExternal("")

and use you code (rp.GetSafeDirDefaultExternal instead of file.DirDefaultExternal)
 
Upvote 0
Top