运行shell命令从Android应用程序文件复制 [英] Running a shell command to copy files from Android App

查看:769
本文介绍了运行shell命令从Android应用程序文件复制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让一个应用程序开始,所以我可以备份我的应用程序到SD卡。我跑:

i'm trying to get an app started so I can backup my apps to sdcard. I ran:

        Process p = Runtime.getRuntime().exec("su");
    Process c = Runtime.getRuntime().exec(
            "cp /data/app/com.ebay.mobile-1.apk"
                    + Environment.getExternalStorageDirectory()
                    + "/ebay.apk");
    Log.d("copy", "done");

当它运行我可以授予超级用户,然后它说,它这样做,但没有文件不会被复制。我只是用eBay的应用为例,测试。

When it runs I can grant super user then it says it's done but there is no file is not copied. I'm just using the eBay app as an example and test.

感谢您的帮助。

修正:感谢下面的帮助,但我发现了一个完整的修复,并在这里做的事情有点不同的方式http://stackoverflow.com/questions/10735273/copy-folders-in-data-data-to-sdcard -viceversa?RQ = 1

Fix: thanks for the help below but i found a full fix and kinda different way of doing things here "http://stackoverflow.com/questions/10735273/copy-folders-in-data-data-to-sdcard-viceversa?rq=1"

推荐答案

Android不支持 CP 命令。为此,你必须要么使用命令(从外壳的)一样,

Android doesn't support cp command. For this you have to either use cat command (from shell only)like,

cat source_file > dest_file

或者使用 BusyBox的您的应用程序。

编辑:

你也可以使用命令

dd if=source_file of=dest_file

这篇关于运行shell命令从Android应用程序文件复制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆