Hi
I'm doing some app which need to copy one .txt file to my other app.
I execute command as super user and file succesfully copies into dir but the file is empty (0 bytes)
What I'm missing. Here is my code:
Other code:
Start command:
I'm doing some app which need to copy one .txt file to my other app.
I execute command as super user and file succesfully copies into dir but the file is empty (0 bytes)
What I'm missing. Here is my code:
B4X:
Dim file1, file2 As String
Other code:
B4X:
Sub GoGoGo
file1 = File.Combine(File.DirAssets, "source.txt")
file2 = "data/data/com.myother.app/files/destination.txt"
PokreniShell("cat" &file1 &" > " &file2)
End Sub
Start command:
B4X:
Sub PokreniShell (comando As String)
Dim Command, Runner As String
Dim StdOut, StdErr As StringBuilder
Dim Result As Int
Runner = File.Combine(File.DirInternalCache, "runner")
Command = File.Combine(File.DirInternalCache, "command")
File.WriteString(File.DirInternalCache, "runner", "su < " & Command)
File.WriteString(File.DirInternalCache, "command", comando & CRLF & "exit") 'Any commands via crlf, and exit at end
StdOut.Initialize
StdErr.Initialize
Result = ph.Shell("sh", Array As String(Runner), StdOut, StdErr)
Msgbox(StdOut.tostring, "")
End Sub