Android 如何在不使用 adb 的情况下将 data/ 的内容复制到 sdcard/?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3555755/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I copy the contentsof data/ to sdcard/ without using adb?
提问by Shrikant Tudavekar
Hi I need to copy/move the contents of data/tombstones
to sdcard/tombstones
嗨,我需要复制/移动内容data/tombstones
到sdcard/tombstones
I'm using the command below:
我正在使用以下命令:
mv data/tombstones /sdcard/tombstones
"failed on 'tombstones' - Cross-device link"
but I'm getting above error.
但我遇到了以上错误。
回答by Dheeraj Bhaskar
You have a SANE VERSION of the mv command
你有一个健全的 mv 命令版本
paraphrasing a few bits from lbcoder from xda and darkxuser from androidforums
解释一些来自 xda 的 lbcoder 和来自 androidforums 的 darkxuser
"failed on 'tombstones' - Cross-device link"
“'tombstones' 失败 - 跨设备链接”
It means that you can't create a hard link on one device (filesystem) that refers to a file on a different filesystem.
这意味着您不能在一个设备(文件系统)上创建一个硬链接来引用另一个文件系统上的文件。
This is an age-old unix thing. You can NOT move a file across a filesystemusing most implementations of mv. mv is not made to copy data from device to device, it simply changes a file's location within a partition. Since /data and /sdcard are different partitions, it's failing.
这是一个古老的 unix 事物。您不能使用 mv 的大多数实现跨文件系统移动文件。mv 不是为了将数据从设备复制到设备,它只是更改文件在分区内的位置。由于 /data 和 /sdcard 是不同的分区,所以它失败了。
Consider yourself fortunate that you have a SANE VERSION of the mv command that doesn't try anyway -- some old versions will actually TRY to do this, which will result in a hard link that points to NOTHING, and the original data being INACCESSIBLE.
想想你自己很幸运,你有一个无论如何都不会尝试的 mv 命令的理智版本——一些旧版本实际上会尝试这样做,这将导致一个指向没有的硬链接,并且原始数据是不可访问的。
The mv command does NOT MOVE THE DATA!!! It moves the HARDLINK TO THE DATA.
mv 命令不会移动数据!!!它将硬链接移动到数据。
If you want to move the file to a different filesystem, you need to use the "cp" command. Copy the file to create a SECOND COPY of it on a different filesystem, and then DELETE the OLD one with the "rm" command.
如果要将文件移动到不同的文件系统,则需要使用“cp”命令。复制文件以在不同的文件系统上创建它的第二个副本,然后使用“rm”命令删除旧文件。
A simple move command:
一个简单的移动命令:
#!/bin/bash
dd if="" of=""
rm -f ""
You will note that the "cp" command returns true or false depending on the successful completion of the copy, therefore the original will only be removed IF the file copied successfully.
您会注意到“cp”命令根据复制的成功完成返回真或假,因此只有在成功复制文件时才会删除原始文件。
OR
或者
#!/bin/bash
cat data/tombstones > sdcard/tombstones
rm data/tombstones
These script can be copied into some place referenced by the PATH variable and set executable.
这些脚本可以复制到 PATH 变量引用的某个地方并设置为可执行文件。
Different Interface
不同的接口
If you need a different interface from adb you may move files using the FileExplorer in DDMS View.
如果您需要与 adb 不同的界面,您可以使用DDMS 视图中的FileExplorer移动文件。
Side note:
边注:
You can move a file into a folder when:
在以下情况下,您可以将文件移动到文件夹中:
- You're
root
; - It is your app directory;
- You've used
chmod
fromadb
or elsewhere to change permissions
- 你是
root
; - 它是您的应用程序目录;
- 您已使用
chmod
fromadb
或其他地方更改权限
回答by samuel.zzy220
Basically you don't have permission to access /data/tombstones in a production version . It seems we have to 'root' the device first. But I failed to root my Samsung S4 which is using Android 4.3
基本上您无权访问生产版本中的 /data/tombstones 。看来我们必须先“root”设备。但是我没有 root 使用 Android 4.3 的三星 S4