Bug? Bug? File.copy works in Debug Mode, but not in Release Mode...

cmweb

Active Member
Licensed User
Longtime User
Hello,

this code

B4X:
Sub Globals
   'These global variables will be redeclared each time the activity is created.
   'These variables can only be accessed from this module.
   Dim quelldir, targetdirectory, quellfile, file1 As String
End Sub

Sub Activity_Create(FirstTime As Boolean)
   quellfile = "2012_Programm.pdf"
   file1 = "2012_Programm.pdf"
   quelldir = "/sdcard/download"
   targetdirectory = "/sdcard/external_sd/Documents"
   File.Copy(quelldir, quellfile, targetdirectory, file1)
End Sub

works well in Debug Mode, but results in an exception when running in Release Mode.

Exception is:

B4X:
Caused by: java.lang.RuntimeException: java.io.FileNotFoundException: /mnt/sdcard/external_sd/Documents/2012_Programm.pdf: open failed: EACCES (Permission denied)

This seems to be a bug...!?
How can I get around it?

Best regards,

Carsten
 

pluton

Active Member
Licensed User
Longtime User
Do you have in your manifest:

B4X:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
 

cmweb

Active Member
Licensed User
Longtime User
Hi,

interesting, that did the trick.

But I never had that line in my manifest and it worked always without any problems...

Is this new?

Best regards,

Carsten
 

cmweb

Active Member
Licensed User
Longtime User
Hi Erel,

1. User selects the directory. So it's existing. The code above was just the sample.

2. As the user selects the directory, I don't use DirRootExternal in that case.

Best regards,

Carsten
 

Djembefola

Active Member
Licensed User
Longtime User
As the user selects the directory, I don't use DirRootExternal in that case.

The permission is added automatically, whenever you use File.DirRootExternal in your application.

B4X:
Dim dummy as String
dummy=File.DirRootExternal 'Get sdcard write permission
 

cmweb

Active Member
Licensed User
Longtime User
That sounds like a good idea...

Best regards,

Carsten

Gesendet von meinem GT-N7000 mit Tapatalk 2
 
Top