2016년 12월 15일 목요일

Please let AI create app-speific folder on the MicroSD at app install time


Android version 4.4 and above does not allow applications you install to write to user-installed MicroSD cardsQuoted from here:

The WRITE_EXTERNAL_STORAGE permission must only grant write access to the primary external storage on a device. Apps must not be allowed to write to secondary external storage devices, except in their package-specific directories as allowed by synthesized permissions. Restricting writes in this way ensures the system can clean up files when applications are uninstalled.

 So still there is a way for the app to write on the MicroSd, but it should be on the package-specific directory.Namely it should be inside the folders:


Normally the folder /Android/data/ is created on the MicroSD card by Android at app install time. But if for some reason the folder doesn't exist in your device, you need to use a system file managerapp to create it. App itself can write inside this folder but it doesn't have the permission to create it.

I checked the apps created by AI and it seems it does not create app-specific directory inside the data or the obb folders in the MicroSd. Even not all playstore apps are creating such app-specific directories in the MicroSd. It seems there is some way to do this at installation time.

I ask the gurus here, how to let the app create these folders in the MicroSd at instalation? Is there any manifest editing required to do so? Any chance that the creators of AI will include this capability in future releases?

Without this app-specific folders created at installation time, the microSd is almost useless for all AI created apps for Kitkat and above!

--
Maybe one of the file extensions can help?
See the extensions section of this FAQ:

-- 
Nope. Did not find any.. Thanks for trying to help though :)

-- 
I can create folder by saving a tiny canvas specifying the whole path and deleting the png after.

Please check these search results I got when searching on the forum for "create folder"

https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!searchin/mitappinventortest/create$20folder%7Csort:relevance

Is this what you need?

-- 
This would work for me too if my path is referring to sdcard which is the internal memory. 

My issue is for the removable secondary storage which some call it external storage (removable MicroSD card). Kitkat and above does not allow to create the folder inside MicroSD card. Unless I create the folder manually in the same name of my package name and inside /Android/data folder of the MicroSd card. The path is for my Gnote3 should be like this:

file:///mnt/extSdCard/Android/data/appinventor.ai_abc.xyz/

the blue folder name cannot be created unless I create it manually!

There is someway to create this app-specific folder in the removable storage (extSdCard) at installation time. How can we achieve this? Without it,  ALL AI applications cannot use the external Sdcard.

-- 

I think you may have missed Italo's point. The search results he linked to indicate a potential solution to your problem. Specifically, the Canvas.SaveAs function will attempt to create every directory on the path you give a file name (via FileUtil.getExternalFile). You can use this mechanism to create the appropriately named directory programmatically in your app. Simply do this before you attempt to write other content to the intended directory.



-- 
I really wished you were right!

Have a look on the attached aia file. And below is a picture too.

I tried this as below, and it did not create the folder in the external SD card (the removable SD card). If you want to try it, you have to modify the path to your External removable SDcard path of your device (because it is device specific; mine was Galaxy S5 Android 6.0.1) . You can find the path of your external sd card in any file manager program in your phone.

The statement of Android documentation is clear that creating a folder in the external removable storage is not permitted UNLESS the folder created at installation time:

The WRITE_EXTERNAL_STORAGE permission must only grant write access to the primary external storage on a device. Apps must not be allowed to write to secondary external storage devices, except in their package-specific directories as allowed by synthesized permissions. Restricting writes in this way ensures the system can clean up files when applications are uninstalled.

  App itself can write inside this folder but it doesn't have the permission to create it.


-- 
For my above example, it seems that the save as for the canvas do not use absolute path. the path:

file:///storage/.....

will be treated as a relative path, and it will create a folder named "file:" inside the internal storage, instead of using the absolute path to write to the external secondary removable SdCard storage. However, extensions like the Taifun File extension can use such full absolute paths without problem. For example that same path above can be used to read an image into the canvas from the external storage. But it fails to write to the external storage using the same path. It will fails to create such folders inside the external storage, but able to write such folders inside the internal sdcard storage if I give it  full absolute path to the internal sdcard storage.

I don't know how to use absolute path with the save as for the canvas in order to be able to write or read from the external storage in the above example. But as I said, in the Taifun extension it will give me a permission error to create any folder in the external secondary storage, but without any problem if the path was the full absolute path to the internal storage.


-- 
I received this link from Jeff, probably we can add this into the file extension...
I will check and will let you know soon... 

I did some Googling about this and found this URL:



-- 

댓글 없음:

댓글 쓰기