program story

adb 명령을 사용하여 SD 카드없이 기기에 파일을 푸시하는 방법

inputbox 2020. 9. 5. 09:53
반응형

adb 명령을 사용하여 SD 카드없이 기기에 파일을 푸시하는 방법


컴퓨터에서 SD 카드가없는 안드로이드 장치로 파일을 푸시하는 방법. 나는 시도했다 :

C:\anand>adb push anand.jpg /data/local
3399 KB/s (111387 bytes in 0.032s)

C:\anand>adb push anand.jpg /data/opt
3199 KB/s (111387 bytes in 0.034s)

C:\anand>adb push anand.jpg /data/tmp
3884 KB/s (111387 bytes in 0.028s)

위의 명령을 사용하여 파일 anand.jpg을 장치 로 이동 했지만 장치에서이 jpg파일을 얻지 못했습니다 . cmd 프롬프트에서 성공 결과를 얻지 못했습니다.

3399 KB/s (111387 bytes in 0.032s).

우분투 터미널에서 아래는 나를 위해 작동합니다.

./adb push '/home/hardik.trivedi/Downloads/one.jpg' '/data/local/'

이 명령을 사용하여 수행했습니다.

통사론: adb push filename.extnsion /sdcard/0/

예: adb push UPDATE-SuperSU-v2.01.zip /sdcard/0/


다음과 같이하세요 :

Android Sdk로 이동 한 다음 터미널 또는 콘솔의 'platform-tools'경로로 이동합니다.

(Mac에서 기본 경로 : / Users / USERNAME / Library / Android / sdk / platform-tools)

장치에 설치된 SD 카드 (외부 및 내부)를 확인하려면 다음 명령을 실행하십시오.

  • 1) ./adb 쉘 (반환 / 입력 누르기 )
  • 2) cd- (반환 / 입력)

이제 Android 장치의 디렉토리 및 파일 목록이 표시됩니다. / sdcard와 / storage를 찾을 수 있습니다.

  • 3) cd / storage (반환 / 입력 누르기)
  • 4) ls (반환 / 입력)

sdcard0 (일반적으로 sdcard0은 내부 저장소) 및 sdcard1 (외부 SDCard가있는 경우)이 표시 될 수 있습니다.

  • 5) 나가기 (반환 / 들어가기)

adb 쉘에서 나오기 위해

  • 6) ./adb push '/Users/SML/Documents/filename.zip'/ storage / sdcard0 / path_to_store / (반환 / 입력 누르기)

파일 복사


때로는 확장이 필요합니다.

adb push file.zip /sdcard/file.zip


먼저 명령 아래 실행

adb root
adb remount

그런 다음 이전에 입력 한 것을 실행하십시오.

C:\anand>adb push anand.jpg /data/local
C:\anand>adb push anand.jpg /data/opt
C:\anand>adb push anand.jpg /data/tmp

외부 저장소가없는 Nexus 4가 있습니다. 그러나 안드로이드는 "/ storage / emulated / legacy"에 마운트 된 "storage"라는 분리 된 파티션을 마운트하기 때문에 하나를 가지고 있다고 생각합니다.adb push anand.jpg /storage/emulated/legacy


내 솔루션 (임의 mp4 비디오 파일이있는 예) :

  1. 장치에 파일 설정 :

    adb push /home/myuser/myVideoFile.mp4 /storage/emulated/legacy/
    
  2. 장치에서 파일 가져 오기 :

    adb pull /storage/emulated/legacy/myVideoFile.mp4 
    

코드에서 경로를 검색하려면 :

String myFilePath = Environment.getExternalStorageDirectory().getAbsolutePath() + "/myVideoFile.mp4";

이게 다야. 이 솔루션은 권한 문제를 일으키지 않으며 잘 작동합니다.

마지막으로 비디오 메타 데이터 정보를 변경하고 싶었습니다. 장치에 쓰기를 원하면에서 권한을 변경해야합니다 AndroidManifest.xml. 다음 줄을 추가하십시오.

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

버전마다 다른 경로가 있기 때문입니다. 다음은 일반적인 솔루션입니다.

경로 찾기 ...

  1. adb shell명령 줄에 입력 합니다.
  2. 그런 다음 ls입력하십시오.

Now you'll see the files and directories of Android device. Now with combination of ls and cd dirName find the path to the Internal or External storage.

In the root directory, the directories names will be like mnt, sdcard, emulator0, etc

Example: adb push file.txt mnt/sdcard/myDir/Projects/


Try this to push in Internal storage.

adb push my-file.apk ./storage/emulated/0/

Works in One plus device, without SD card.


You are trying to write to system folders. With ADB you have root (admin) access so you see the system folders of which sdcard is one of them so to send a picture you could use

D:\Program Files\Android\sdk\platform-tools\adb push am files\android sdk\adb.exe push C:\Downloads\anand.jpg /sdcard/pictures/

NB: C:\Downloads\anand.jpg replace with path and name to picture..


Certain versions of android do not fire proper tasks for updating the state of file system. You could trigger an explicit intent for updating the status of the file system. (I just tested after being in the same OP's situation)

adb shell am broadcast -a android.intent.action.MEDIA_MOUNTED -d file:///

(You could pass a specific filepath instead of file:/// like file:///sdcard )


In my case, I had an already removed SDCard still registered in Android. So I longpressed the entry for my old SDCard under:

Settings | Storage & USB

and selected "Forget".

Afterwards a normal

adb push myfile.zip /sdcard/

worked fine.

참고URL : https://stackoverflow.com/questions/20834241/how-to-use-adb-command-to-push-a-file-on-device-without-sd-card

반응형