File copy from Assets dir not working

kanaida

Active Member
Licensed User
Longtime User
Steps to reproduce:

Create a new project
Add a file on the right pane, any file.

'This returns True:
File.Exists(File.DirAssets,"YourFileName")

'This fails
File.Copy(File.DirAssets,"YourFileName",File.DirExternal,"YourFileName")

Says something like:
/sdcard/YourFileName File Not found (strangely returning the target filename and not the source filename)

All i'm trying to do is copy a native linux executable to a temp dir where I can give it execution rights, then run it as a shell command. My command works fine if i do all of this from the shell manually.
 

kanaida

Active Member
Licensed User
Longtime User
I think /sdcard/

however, even if I manually type a path I know to exist, same problem.

My actual path is /sdcard/tmproot wich I've actually created myself by hand in advance.
 

vb1992

Well-Known Member
Licensed User
Longtime User
Or test this out, if it works, then add your file to it,
and replace the file-name, and test again
 

Attachments

  • SimpleFileCopy.zip
    23.6 KB · Views: 558

rbsoft

Active Member
Licensed User
Longtime User
B4X:
File.Copy(File.DirAssets,"YourFileName",File.DirEx ternal,"YourFileName")

Remove the blank in File.DirEx ternal. Should be

B4X:
File.Copy(File.DirAssets,"YourFileName",File.DirExternal,"YourFileName")

Rolf
 

kanaida

Active Member
Licensed User
Longtime User

lol... wish it was that, if this was the case it wouldn't compile I'm gonna try DirExternal and see what happens.
 

kanaida

Active Member
Licensed User
Longtime User
hmmm... File.DirInternal worked. I guess that will do.

Sdcard was an internal memory partition, it's fine though. I just needed a file to execute from an ext filesystem. Thanks guys
 

kanaida

Active Member
Licensed User
Longtime User
Something else is kinda funny.

Using root explorer, I can create files without any special root access in :
/data/local/tmp/

However, if I execute say:
cp /data/data/kanaida.myapp/files/MyFile /data/local/tmp I get access denied? Is there anything special about permissions that android apps get on the filesystem itself? strangely, I can access this folder with adb shell and push files into it.
 

kanaida

Active Member
Licensed User
Longtime User
After reading a little bit more about android permissions, is there any way I can give myself elevated filesystem and process execution rights somehow?

I have a suspicion this is what it could be.

The reason for all of this is because I'm converting an ADB script that roots a phone, into a single APK file (that won't be on the market for obvious reasons) but will make life a whole lot easier for the people who install my paid app wich requires root priviliges, not to mention reduce the chance of them doing something incorrectly themselves.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…