Android Question Getting error when copy files

Ajws

Member
Licensed User
Hi all, help me....i'm gettting error when copying data this is error message
B4X:
    If File.Exists(File.DirInternal,"dbpo.db") = True Then
        Msgbox("FOUND","")
      
          File.Copy(File.DirInternal,"dbpo.db",File.DirDefaultExternal ,"dbpo.db")
    End If
java.io.FileNotFoundException: /storage/emulated/0/Android/data/alam.com/files/dbpo.db: open failed: ENOENT (No such file or directory)

File.DirDefaultExternal -> read only ???
 

Ajws

Member
Licensed User
1. Don't use Msgbox. Use Log instead.
2. What is the value of targetSdkVersion in the manifest editor?
3. What is the output of Log(File.DirExternalWritable)?
i use :
B4X:
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="23"/>

B4X:
B4A Version: 7.30
Parsing code.    (0.10s)
Compiling code.    Error
Error compiling program.
Error description: Unknown member: direxternalwritable
Error occurred on line: 329
Log(File.DirExternalWritable)
Word: direxternalwritable
 
Upvote 0

Ajws

Member
Licensed User
It should be File.ExternalWritable

Anyway, if targetSdkVersion >= 23 then you should use RuntimePermissions.GetSafeDirDefaultExternal instead of File.DirDefaultExternal:
https://www.b4x.com/android/forum/threads/runtime-permissions-android-6-0-permissions.67689/#content
This is my manifest...
B4X:
'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: https://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="23"/>
<supports-screens android:largeScreens="true" 
    android:normalScreens="true" 
    android:smallScreens="true" 
    android:anyDensity="true"/>
     
   
    )
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
 AddManifestText(
<uses-permission
  android:name="android.permission.WRITE_EXTERNAL_STORAGE"
  android:maxSdkVersion="18" />
)

B4X:
    Log(File.ExternalWritable)  ' ---> return true

but still error

java.io.FileNotFoundException: /storage/emulated/0/Android/data/alam.com/files/dbpo.db: open failed: ENOENT (No such file or directory)
 
Upvote 0
Top