^can you file a bug report
Plugin Bug Report sent.
I look forward to your instructions.
Thank you very much
Hello, Scott.
Any news about this topic?
We need to implement the SD card access management shortly, so we would appreciate it if you could give us your feedback as soon as possible.
Thanks.
J. M. Flores
I sorry, I usually don’t take this long but I lost my usb c to micro usb cable and have been in Disney world all week. I should be back home on Sunday.
Hi Scott
I buyed the External Storage plugin, and I can create a new folder using :
externalStorage.makeFolder("/NewFolder", shouldLookAtRoot)
But i can’t get the path of this folder (ShouldLookAtRoot) … I can see this folder in my device, works 100%, but i need get the path …
how can I get the path ?
Ps: I tryng
externalStorage.getExternalFilesDir(type)
and
externalStorage.getExternalFilesDir(shouldLookAtRoot)
and
externalStorage.getExternalFilesDir("NewFolder)
But this is catching a different path, not the “root” path where the “NewFolder” was created
Looking into this try
externalStorage.getExternalFilesDir("NewFolder”, true)
Not works …
This give-me the following result:
“/storage/emulated/0/Android/data/com.Myproject/files/NewFolder”
The correct answer would be:
“/storage/emulated/0/NewFolder”
I can modify this using the api of corona sdk, but I don’t know if all devices have the same path “Android/data/com.Myproject/files/” to exclude, so I need the correct path :\
Scott ?
Sorry been busy looking at now
This should be patched
Can you tell me when you can fix this?
I am trying to use the externalStorage plugin to copy a file the Downloads folder on Android.
My code is as follows:
local pathCorona = system.pathForFile( "TESThello123.txt", system.ResourceDirectory ) local pathOnDevice = "/Download/hello123.txt" local extStorageResult = externalStorage.copyFile(pathCorona, pathOnDevice)
I get the result “file saved” but I don’t see the file anywhere on the phone.
I also tried leaving out the Download/ from the pathOnDevice as follows: local pathOnDevice = “/hello123.txt”
but I still don’t see the file anywhere on the phone.
I see the build settings file mentions – android > 6 so I have tried the experiments above with two phones that are android 5.1 and android 7, but I don’t see the file on either phone.
Where did the file get saved?
How sure about this path are you?
local pathOnDevice = "/Download/hello123.txt"
That looks awfully short for a download folder on an android device. My experience tells me that folder either doesn’t exist, or if you’re hoping it gets created, it won’t due to permissions.
I may be wrong about this, but in my time looking at folder hiearchies on Android they are all deep, they often vary and permissions are an issue.
Q: Isn’t there a plugin on the marketplace that lets you request the path for downloads/etc on the device your user is using? I thought there was.
As I’ve been following the topic to always see if it has been fixed the command to get the right path to
"externalStorage.makeFolder (" / NewFolder, shouldLookAtRoot) "
I can state what Scott said, his path to the download folder is missing, the same is for me, I need to create a folder in the “general folder” of the android and get her way, which I still can not …
To copy items to the Download folder you can use the ssk plugin , but unfortunately for me it does not solve this problem =/
Hi again.
I don’t own this plugin so I have to guess a little, but the plugin docs show this function is used to get a path right?
local path = externalStorage.getExternalFilesDir( type ) print("Path: ", path )
I’m not clear on what ‘type’ should be. I’ll leave that to you.
However, assuming you can get the above two lines to work and print a full path to the console, then this ssk.files.* code should do the job of copying a file from documents to the path (from above)
-- 1. Build destination path root (downloads folder or whatever) local path = externalStorage.getExternalFilesDir( ????? ) -- 2. Build source path local src = ssk.files.documents.getPath( "hello123.txt" ) print( dst ) -- 3. Build full destination path local dst = path .. "/hello123.txt" -- 4. Copy the file ssk.files.util.cpFile( src, dst )
See here for more on installing and using SSK:
https://roaminggamer.github.io/RGDocs/pages/SSK2/#installing-ssk2
I’m not totally sure about that path. Earlier in this topic Scott H had written
“if you want [to get] a file in the downloads folder you would do externalStorage.getFile(”/Download/test.txt", pathDocs)"
And so I used that path.
On my old phone (with android 5.1), I can see a “Download” folder right under the root (or actually under “Internal Storage”) and that folder has the same files that I see when I use the phone’s “Downloads” app to look for files. I see that by plugging it into my PC and browsing it as a USB device. On my newer phone, I can’t see anything when when I browse the phone as a USB device. Maybe something has changed.
Anyway, I think that path is good for this plugin. On the other hand, I have some confusion about the names Internal Storage and External Storage. I believe the path “/Download/” refers to a folder under the phones’s Internal Storage rather than on any SD card, which might be considered “external storage” and that seems to be consistent with what I see on my old phone. On the third hand, I don’t see the file!
As a side question, do you happen to know about writing to external storage on iPhones? Specifically, assuming I get this worked out on Android, I’m thinking the procedure for the Apple world will be to
- Buy another, different plugin for Apple
- Put a test for operating system in my code, using system.getInfo()
- Call the appropriate plugin
Is that the basic idea?
Also, thanks for the info about the ssk plugin. I’ll check that out.
Hello again externalStorage fans,
I can now report that after working on this all day, on and off, it now works. Strangely, the code that now works is the same code I started with this morning.
I did notice that during the day, the externalStorage plugin got updated, but it didn’t observe that the function had worked until this evening. In fact, I saw the first success this evening sometime after an Android system update (7.0 to 8.1) was pushed to my phone. Probably an unrelated event – or maybe they were chasing this bug too.
Anyway, it has now worked the last 3 times I tried it with 3 different test files.
I’m going to bed now. I’ll look at it some more tomorrow and try it with the actual files I want to use, instead of test files.
Hello again. Here’s some info from my day of experiments with externalStorage plug-in, and externalStorage.copyFile, yesterday.
Path does seem to be important, or at least interesting, in this matter.
The original path I supplied for the destination file (on the Android phone) was:
/Download/hello123.txt
That path did not work yesterday morning but did work yesterday evening. By “work” I mean: “caused the externalStorage plugin to write a test file that could be seen using the Android app called Downloads/Files on Android phone.” One note on this definition is that during my day of testing yesterday (2018-11-09), my Android phone updated itself from 7 to 8.1.0 After the update, the “Downloads” app had been replaced by the “Files” app.
At one point I used the plugin-method externalStorage.getExternalFilesDir(type) as follows: externalStorage.getExternalFilesDir( “Download” ). That returned the following string:
/storage/emulated/0download/hello123.txt
At first, I thought that was an Ah ha moment, but using that path and then using either the externalStorage plug-in or, later in the day, the SSK library, did not “work.” Both caused the following runtime error message which might be of use to someone that knows the Android world:
Attempt to invoke interface method ‘boolean java.nio.channels.WritableByteChannel.isOpen()’ on a null object reference
After the Android update, I saw the first evidence that any of my experiments had caused a test file to be written to the phone. If I believe the file date stamp reported by the new Files application, one of the days earliest attempts, before I wrote to this forum, had worked – I could view the file “hello123.txt”
I had to try it a few more times, backing out different changes and trying different files, but eventually I got the original code to work multiple times. I skipped a few numbers in my file numbering, but I can now see the file hello999.text. When I view it with Chrome, the path shown n the URL edit box is:
content://com.android.providers.downloads.documents/document/raw%3A%2Fstorage%2Femulated%2F0%2FDownload%2Fhello999.txt
BTW %3A is the colon character ( : )
So, one thing I know is that the path to the Download directory that is needed by externalStorage plug-in is not the same as the one reported by Chrome, or even by the externalStorage plug-in itself.
That’s it for now.
Glad you got it sorted out, path is very different for different versions of Android and sometimes different devices
So “externalStorage.getExternalFilesDir( “Download” )” returning the right path now?