Skip to first unread message

吳勝傑

unread,
Aug 11, 2016, 8:27:09 PM8/11/16
to MIT App Inventor Forum
Hey everyone~

I am trying to make an app to copy file from assets.

and java is really pain in the ass, so i am using App Inventor 2 now.

 so far it seem's i can only copy file from sdcard by using Taifun's file extension 

which means no access to assets. i am really depress now.


any idea? or i should start with java?

Taifun

unread,
Aug 11, 2016, 8:37:01 PM8/11/16
to MIT App Inventor Forum
using my file extension https://puravidaapps.com/file.php you can copy a file from anywhere to anywhere except to the assets, because this is not possible in Android


Copy file.
Prefix the filename with / (i.e. relative path) to copy a file on the SD card. For instance /myFile.txt will copy the file /mnt/sdcard/myFile.txt. To copy assets packaged with an application (also works for the Companion) start the fromFilename with // (two slashes). However you can't copy files to the assets. If a fileName starts with file:/// you can specify a complete path to the file.

Note: For copying a file to an external sdcard, there are the following restrictions: an app can only write to its own directory but can't create its own directory (example: appinventor.ai_MxyzptlkHavok.fileTest). Subdirectories will only be created if an app is writing to its own directory. Thank you MxyzptlkHavok for your tests!
If you try to write to another directory on the external sdcard, you will get an error message "open failed: EACCES (Permission denied)", see also here.



Taifun

吳勝傑

unread,
Aug 11, 2016, 9:25:57 PM8/11/16
to MIT App Inventor Forum
Dear Taifun, thanks for your time & reply. i do download your awesome extension and example for testing. and yes it works on sdcard copy.
but there is one thing i am not sure, when i trying to copy from assets to sdcard. I saw some strange message.
don't know if you can help with this. i'll be really appreciate.


for the record, i am using emulator Nox , which have root access

, also have directory "Al" build in SD. tried your third example already which is copy file from SD to SD and it works.


nice extension by the way.


 

Taifun

unread,
Aug 11, 2016, 9:56:26 PM8/11/16
to mitappinv...@googlegroups.com
when i trying to copy from assets to sdcard. I saw some strange message.
what you are doing is not to copy a file from the assets, you are trying to copy a file from file:/// and my guess is, you can't access it there
to copy a file from the assets you first upload the file into App Inventor and then use just the filename like this //WooHoo.pdf
you might want to read again the documentation, see also my last post in this thread

 To copy assets packaged with an application (also works for the Companion) start the fromFilename with // (two slashes). 

Taifun

吳勝傑

unread,
Aug 14, 2016, 12:00:53 PM8/14/16
to mitappinv...@googlegroups.com
thank you very much, i do discribe my question wrong, the only thing i want is to access the root(moving file from /data to /data). and your method works all fine.
including sd to sd copy & copy from root by using file:/// but no destination to root and that's exactly what i want. which means i need something capable of asking superuser permission before copy. I tried 2 day but no clue. hoping i can get some tip from here.

and sorry for late reply. was kind of busy.

吳勝傑

unread,
Aug 21, 2016, 8:22:05 AM8/21/16
to MIT App Inventor Forum
problem solved, i used gscript to mount data directory to sdcard. no root access anymore, thanks
Reply all
Reply to author
Forward
0 new messages