Android Question Permission Problem?

spaceman

Member
Licensed User
Longtime User
Hi

I am trying to use the Archiver library to create a ZIP File,
and when I run this code:
B4X:
Dim O_Archiver As Archiver
O_Archiver.ZipFolder("/sdcard/Alarms/","/sdcard/","MyFirstZIP.zip","NoneForNow")

I get this error:
332qfxc.png



Is this a permission problem?
Should I add anything to the project?


Thank you
 

spaceman

Member
Licensed User
Longtime User
Hi Giga and Erel.

Thank you.



Did you try mnt/sdcard/Alarms?
When changing to that, it did not help.


also check the manifest.
Add the following line to the manifest file using the manifest editor:
< uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
when adding that Permission in the Manifest, it did help..
(both with the "/sdcard/" path and the "/mnt/sdcard/" one)



You should use File.DirRootExternal instead of /sdcard. The actual path is different on different devices and it will add the permission automatically.
This indeed also helped. When I changed it to:
B4X:
O_Archiver.ZipFolder(File.DirRootExternal&"/Alarms/","/sdcard/","MyFirstZIP.zip","NoneForNow")
It worked.
(when using File.DirRootExternal, I do not need to add the Permission to the manifest..)


BTW
"DirRootExternal" sounds like the path to the external SD Card no?

In my case, I do not have an SD Card in the device,
but If I add one, will File.DirRootExternal resolve to something else?


(if not, then, if File.DirRootExternal="/mnt/sdcard", what will refer to the External Storage(SD Card) when it's available?)


Also it makes me wonder:
Archiver's .ZipFolder() method does not include the needed permission?
File.DirRootExternal causes it to be included, so shouldn't Archiver.ZipFolder() include it too?
 
Last edited:
Upvote 0

spaceman

Member
Licensed User
Longtime User
OK I understand.

And regarding this question:

Archiver's .ZipFolder() method does not include the needed permission?
File.DirRootExternal causes it to be included, so shouldn't Archiver.ZipFolder() include it too?

Maybe Archiver.ZipFolder() should be updated to include the needed Write permission?
 
Upvote 0

spaceman

Member
Licensed User
Longtime User
OK I understand.


1 more thing I am trying to do:
I need to ZIP a collection of files and folders into one ZIP file.

Currently I can only ZIP files, or 1 folder.
Is there any chance this library can be updated to include a method that will be called for example
.ZipItems(),
which will receive an array of items,
(items can be either files, or folders.. foler will end with a '/'),
and that way a developer will be able to ZIP all items to one ZIP file?
 
Upvote 0
Top