如何通过命令提示符从Android设备中的SD卡读取文本文件?

时间:2021-12-23 09:00:49

There is a folder called "D_Permision" SD Card and there is a text file called "permission.txt" in it.

有一个名为“D_Permision”SD卡的文件夹,其中有一个名为“permission.txt”的文本文件。

I want to read this text file through command prompt and display its content in the command prompt(Not in a separate file)

我想通过命令提示符读取此文本文件并在命令提示符下显示其内容(不在单独的文件中)

When I use

我用的时候

adb pull permission.txt /sdcard/D_Permission

it gives following error

它给出了以下错误

remote object 'permission.txt' does not exist.

远程对象'permission.txt'不存在。

but I used

但我用过

adb push permission.txt /sdcard/D_Permission  

(successfully added permission.txt to D_Permission folder)

(已成功将permission.txt添加到D_Permission文件夹)

and the tried to pull.but I get same error.

并试图拉。但我得到同样的错误。

sdcard/D_permission has both read / write permission

sdcard / D_permission具有读/写权限

So how to read this text file through command prompt and display its content in the cmd?

那么如何通过命令提示符读取该文本文件并在cmd中显示其内容?

2 个解决方案

#1


You don't need to pull the file. adb provides shell acces, so you can do a cat:

您无需提取文件。 adb提供shell访问,所以你可以做一个猫:

adb shell cat /sdcard/D_Permission/foo.txt

If the file does not exist though, you'll still get "does not exists" error of course, which is normal.

如果文件不存在,你当然会得到“不存在”的错误,这是正常的。

#2


I directly use the path "/mnt/external_sd/.. Path of File.".

我直接使用路径“/ mnt / external_sd / .. Path of File。”。

But it was only work with my Device

但它只适用于我的设备

Maybe you forget these permissions.

也许你忘了这些权限。

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

#1


You don't need to pull the file. adb provides shell acces, so you can do a cat:

您无需提取文件。 adb提供shell访问,所以你可以做一个猫:

adb shell cat /sdcard/D_Permission/foo.txt

If the file does not exist though, you'll still get "does not exists" error of course, which is normal.

如果文件不存在,你当然会得到“不存在”的错误,这是正常的。

#2


I directly use the path "/mnt/external_sd/.. Path of File.".

我直接使用路径“/ mnt / external_sd / .. Path of File。”。

But it was only work with my Device

但它只适用于我的设备

Maybe you forget these permissions.

也许你忘了这些权限。

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />