I would like to open an image file located in a folder on my phone.
Rotate the image and save it under another name in a folder on your phone.
It doesn’t really seem like a complicated problem.
But in Kodular I’m wasting a lot of time without reaching a solution.
Even though it’s ridiculous, it seems like Kodular’s standard features don’t allow this.
Do I have to use extensions?
Can someone help me?
You can find extensions for image manipulation in the extensions directory
For example the image extension is able to rotate an image located in ASD… App Inventor Extensions: Image | Pura Vida Apps
Taifun
OK.
I loaded the extension.
But I don’t understand how to write the image file to a folder on the phone.
Can you help me?
Use the file component and its Copy method to copy the file from ASD to shared storage
Taifun
As recommended by Taifun (thank you very much) I tried using the File.Copy component.
This component uses folder paths based on what you select in FileScope:
App: \storage\emulated\0\Android\data\io.makeroid.companion\files
Assets: \storage\emulated\0\Android\data\io.makeroid.companion\files\assets
Cache: \storage\emulated\0\Android\data\io.makeroid.companion\cache
Legacy: \storage\emulated\0\Android\data\io.makeroid.companion\files\data\ (same as Private?)
Private: \storage\emulated\0\Android\data\io.makeroid.companion\files\data\ (same as Legacy?)
Shared: \storage\emulated\0\
Obviously “io.makeroid.companion” is the name of the application installation folder.
So if I want to check the existence of “/storage/emulated/0/X.txt” I have to use the File1.Exists(FileScope Shared, “/X.txt”) block
So if I want to check the existence of “/storage/emulated/0/DCIM/X.txt” I have to use the File1.Exists(FileScope Shared, “/DCIM/X.txt”) block
Too bad that if I try to use the Copy method it doesn’t work and kicks me out of companion.
This happens if I use FileScope=Shared. If I use FileScope=App it works but it’s NOT what I need.
I am very demoralized.
If Kodular initially exhilarated me, now that I’ve tried it for some time, I find it VERY VERY lacking.
The basic components are very limited, often do not work in all parts and are NOT well documented and lack examples of use.
For everything you need an extension.
Maybe it’s time to abandon everything and move on to direct programming with Android Studio.
No, you do not have access to the root directory… you will have to use SAF for that
Therefore also your screenshot does not make sense
Your goal is to copy a file from ASD to shared storage, isn’t it?
Please read also Some basics on Android storage system
Taifun
Theoretically this is correct, but rhe DCIM directory is used for images
Taifun
If it were true there would be some logic.
But if I try to verify the existence of the file using the File.Exists method it also works on the root directory.
So I would say that means I have read access.
If I try to create a folder always on the root directory with the File.MakeDirectory method it works.
So it makes you think you also have write access.
If I try with File.CopyFile to copy a file from the root directory to the root directory (from /storage/emulated/0/X1.jpg to /storage/emulated/0/X2.jpg) but it DOESN’T work and it crashes directly and the companion closes.
I can’t find the logic…
My goal would be to simply copy the file “/storage/emulated/0/X1.jpg” as “/storage/emulated/0/X2.jpg”
N.B.
Yes, it is very clear that the “/storage/emulated/0/DCIM” folder is used for photos.
N.B. Acronyms:
- ASD (Application Specific Directory)
- SAF (System Authorization Facility)
Yes, for media files everywhere except of /Android/data
This might depend on the Android version of your test device
For newer versions you might have to use SAF - storage access framework SAF: App Inventor implementation of Storage Access Framework
I would do what is easily doable with the file component only… which is accessing shared storage like /Download
Make your life easy and not complicated…
Check also again Some basics on Android storage system
Copy from /storage/emulated/0/Download/yourFolder/X1.jpg to /storage/emulated/0/Download/yourFolder/X2.jpg
Taifun
By dint of banging my head, I found the solution.
My old acquaintance of DOS has borne fruit.
The double dots point to the parent folder.
So from the /storage/emulated/0/Android/data/io.makeroid.companion/files folder I can go down to the /storage/emulated/0 folder
From here I have access to everything. Also to the /storage/emulated/0/DCIM photo folder
I’ve tried: I can read, write, copy and erase without any problems.
Maybe for other purposes, but here it’s completely unnecessary.
And of course this only works on Android < 11 with storage permissions. On Android 11+, files can no longer be saved/copied to the root dir of the external storage. Read access for media files exists for almost all locations in the external storage.
Read this carefully and you should understand:
I verified. You’re right, the game of dots to move between folders is not needed in copying.
Legacy points directly to the /storage/emulated/0 folder.
In the previous post, I don’t know why, I mistakenly put "Legacy: \storage\emulated\0\Android\data\io.makeroid.companion\files\data"
But the dots become useful for erasing. If I don’t use them I can only delete files contained in the …files\ folder or its subfolders.
Without relying on additional extensions, do you have alternatives to delete the 1a.jpg and 1b.jpg files that in your example you created in the Legacy folder? With “the dots” you can do it…
I would like to point out that for testing I use my Huawei Mate 20 Pro (LYA-L09) phone, with the following build version: 12.0.0.142
According to what you say I shouldn’t be able to save or copy. Or did I misunderstand?
It’s all about the Android version and not about any build version / internal manufacturer-dependent OS.