S spaceman Member Licensed User Longtime User Jan 20, 2014 #1 Hi I am trying to use the Archiver library to create a ZIP File, and when I run this code: Code: Copy Dim O_Archiver As Archiver O_Archiver.ZipFolder("/sdcard/Alarms/","/sdcard/","MyFirstZIP.zip","NoneForNow") I get this error: Is this a permission problem? Should I add anything to the project? Thank you
Hi I am trying to use the Archiver library to create a ZIP File, and when I run this code: Code: Copy Dim O_Archiver As Archiver O_Archiver.ZipFolder("/sdcard/Alarms/","/sdcard/","MyFirstZIP.zip","NoneForNow") I get this error: Is this a permission problem? Should I add anything to the project? Thank you
giga Well-Known Member Licensed User Longtime User Jan 20, 2014 #2 Did you try mnt/sdcard/Alarms? 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"/> Upvote 0
Did you try mnt/sdcard/Alarms? 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"/>
Erel B4X founder Staff member Licensed User Longtime User Jan 20, 2014 #3 You should use File.DirRootExternal instead of /sdcard. The actual path is different on different devices and it will add the permission automatically. Upvote 0
You should use File.DirRootExternal instead of /sdcard. The actual path is different on different devices and it will add the permission automatically.
S spaceman Member Licensed User Longtime User Jan 20, 2014 #4 Hi Giga and Erel. Thank you. giga said: Did you try mnt/sdcard/Alarms? Click to expand... When changing to that, it did not help. giga said: 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"/> Click to expand... when adding that Permission in the Manifest, it did help.. (both with the "/sdcard/" path and the "/mnt/sdcard/" one) Erel said: You should use File.DirRootExternal instead of /sdcard. The actual path is different on different devices and it will add the permission automatically. Click to expand... This indeed also helped. When I changed it to: Code: Copy 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: Jan 20, 2014 Upvote 0
Hi Giga and Erel. Thank you. giga said: Did you try mnt/sdcard/Alarms? Click to expand... When changing to that, it did not help. giga said: 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"/> Click to expand... when adding that Permission in the Manifest, it did help.. (both with the "/sdcard/" path and the "/mnt/sdcard/" one) Erel said: You should use File.DirRootExternal instead of /sdcard. The actual path is different on different devices and it will add the permission automatically. Click to expand... This indeed also helped. When I changed it to: Code: Copy 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?
Erel B4X founder Staff member Licensed User Longtime User Jan 20, 2014 #5 File.DirRootExternal points to the default "external storage". On almost all of the devices this is an internal storage and not a real sd card. Upvote 0
File.DirRootExternal points to the default "external storage". On almost all of the devices this is an internal storage and not a real sd card.
S spaceman Member Licensed User Longtime User Jan 20, 2014 #6 Erel said: File.DirRootExternal points to the default "external storage". On almost all of the devices this is an internal storage and not a real sd card. Click to expand... So what Enum points to the SD Card (when one exists in the device)? Upvote 0
Erel said: File.DirRootExternal points to the default "external storage". On almost all of the devices this is an internal storage and not a real sd card. Click to expand... So what Enum points to the SD Card (when one exists in the device)?
Erel B4X founder Staff member Licensed User Longtime User Jan 20, 2014 #7 There is no API in Android to find the second external storage if such exists. There are several discussions in the forum about this issue. There are some common paths. Upvote 0
There is no API in Android to find the second external storage if such exists. There are several discussions in the forum about this issue. There are some common paths.
S spaceman Member Licensed User Longtime User Jan 20, 2014 #8 OK I understand. And regarding this question: spaceman said: 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? Click to expand... Maybe Archiver.ZipFolder() should be updated to include the needed Write permission? Upvote 0
OK I understand. And regarding this question: spaceman said: 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? Click to expand... Maybe Archiver.ZipFolder() should be updated to include the needed Write permission?
Erel B4X founder Staff member Licensed User Longtime User Jan 21, 2014 #9 No. The permission is only needed if you access the external storage. It will be added when you use File.DirRootExternal or File.DirDefaultExternal. Upvote 0
No. The permission is only needed if you access the external storage. It will be added when you use File.DirRootExternal or File.DirDefaultExternal.
S spaceman Member Licensed User Longtime User Jan 21, 2014 #10 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
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?