Android adb推送到没有SD卡且没有root访问权限的设备中的位置
如果设备没有 SD 卡并且我们没有 root 访问权限,那么 Android 设备上是否有任何位置可以推送文件(使用 adb)?
(我正在尝试将属性文件推送到设备上,因此我还需要能够从设备上运行的活动内的此位置读取数据)
Is there any location on an android device that we can push a file (using adb) if the device has no SD card and we do not have root access?
(I am trying to push a properties file onto the device, so I will also need to be able to read from this location inside an activity running on the device)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
每个设备都有不同的能力。在某些手机上,例如 Samsung Galaxy S Vibrant,/sdcard/ 挂载点可由通过 adb 连接的任何主机写入。在其他设备上,例如 MyTouch 4G,“adb Push”根本无法将任何文件发送到任何目的地。
如果您仅使用一两个设备进行测试,请打开
adb shell
并发出df
和ls -l
等命令来查看安装的内容分别有点和文件权限。如果您的用户可以在 Android 设备上执行
find
,那真是一个福音,您可以使用它来查找当前有效 uid 可写(或所有人都可写)的文件。一些可以尝试的目录:
您可能已经看过 adb 页面,但是我将其链接以防万一。
示例 df 输出:
Every device has the capacity to be different. On some phones, such as the Samsung Galaxy S Vibrant, the /sdcard/ mount is writeable by any host connected through adb. On others, such as the MyTouch 4G, 'adb push' cannot send any files to any destination at all.
If you are testing with just one or two devices, open an
adb shell
and issue commands such asdf
andls -l
to see what mount points there are, and the file permissions, respectively.If your user can execute
find
on the Android device, that's a real boon and you can probably use that to locate files writeable by the current effective uid (or writeable by all).Some directories to try:
You've probably already seen the adb page but I'm linking it just in case.
Example
df
output:ADB 推送似乎与“/data/local/tmp”配合良好。
ADB push seems to work fine with '/data/local/tmp'.
/data/local 通常可由 shell 用户(运行 adb shell 的用户)读写。所以你应该能够 adb 将文件推送到 /data/local。
为了使应用程序能够访问它,您还必须适当地设置文件的权限
另一种方法是让您的应用程序在设备上的应用程序数据目录下创建一个新目录,并设置权限该目录是世界可读/可写的,这应该允许您 adb Push 到那里。
/data/local is typically readable and writeable by the shell user (the user that adb shell runs under). So you should be able to adb push a file to /data/local.
In order for an application to be able to access it, you'll also have to set the permissions on the file appropriately
Another approach would be to have your application create a new directory under it's application data directory on the device and set the permissions on the directory to be world readable/writeable, which should allow you to adb push to there.