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.