Tuesday, June 23, 2015

How to copy/push & delete file in sdcard(DDMS) by using commnad line in android?

Push file to DDMS/File Explorer ->storage/sdcard/nature.jpg

1. Go to commandline
2. Type following path
       E:\MyProject\adt-bundle-windows-x86\sdk\platform-tools>
3. Type
      adb push [your file]  /storage/sdcard

      adb push E:\Images\nature.jpg  /storage/sdcard

if u get error msg

 failed to copy 'E:\Images\nature.jpg' to '/storage/sdcard/nature.jpg': Read-only file system

then change read only mode to write/execute mode means give full permission to '/storage/sdcard'
for this go to following command

4. E:\MyProject\adt-bundle-windows-x86\sdk\platform-tools>adb shell
 a.   
root@generic:/ # su
        su
 b.   
root@generic:/ # mount -o rw,remount rootfs /
        mount -o rw,remount rootfs /
 c.   
root@generic:/ # chmod 777 /storage/sdcard
        chmod 777 /storage/sdcard
 d.   
root@generic:/ # exit
        exit
 e.  
root@generic:/ # exit
       exit

The folder has changed mode read to write/excute mode. Then push a file to '/storage/sdcard'
5. Type
       E:\MyProject\adt-bundle-windows-x86\sdk\platform-tools>adb  push E:\Images\nature.jpg  /storage/sdcard

 1067 KB/s (11670528 bytes in 10.677s)

You have sucessfully transfered nature.jpg to /storage/sdcard
You can see file in DDMS/File Explorer ->storage/sdcard/nature.jpg

Delete file from DDMS/File Explorer ->storage/sdcard/nature.jpg

1. Go to commandline
2. Type following path
       E:\MyProject\adt-bundle-windows-x86\sdk\platform-tools>
3. Type
       E:\MyProject\adt-bundle-windows-x86\sdk\platform-tools>adb shell 

 a.  root@generic:/ # cd storage
       cd storage
 b.  root@generic:/storage # cd sdcard
       cd sdcard
 c.  root@generic:/storage/sdcard # rmdir nature.jpg
      rmdir nature.jpg


Note : Make sure your dir should be empty.
For non-empty directory use.

 d.  root@generic:/storage/sdcard # rm -r nature.jpg
      rmdir nature.jpg

Create file/folder to DDMS/File Explorer ->storage/sdcard/test

1. Go to commandline
2. Type following path
       E:\MyProject\adt-bundle-windows-x86\sdk\platform-tools>
3. Type
       E:\MyProject\adt-bundle-windows-x86\sdk\platform-tools>adb shell 

 a.  root@generic:/ # cd storage
       cd storage
 b.  root@generic:/storage # cd sdcard
       cd sdcard
 c.  root@generic:/storage/sdcard # mkdir test
      

if u get error msg

mkdir: 'test': Permission denied

d.  root@generic:/storage/sdcard # su

c.  root@generic:/storage/sdcard # mkdir test

Done


4. Go to in folder
a. root@generic:/storage/sdcard # cd test
b. root@generic:/storage/sdcard/test # 

No comments:

Post a Comment