How to push files to an emulator instance using Android Studio

前端 未结 8 447
温柔的废话
温柔的废话 2020-12-23 15:34

How am I able to push .txt files to the emulator using Android Studio?

相关标签:
8条回答
  • 2020-12-23 16:04

    One easy way is to drag and drop. It will copy files to /sdcard/Download. You can copy whole folders or multiple files. Make sure that "Enable Clipboard Sharing" is enabled. (under ...->Settings)

    0 讨论(0)
  • 2020-12-23 16:05

    Update (May 2020): Android studio have new tool called Device File Explorer. You can access it in two way:

    1. By clicking on Device File Explorer icon in right bottom corner of android studio window.
    2. If you could not find its icon, inside Android Studio press shift button twice. Quick search window will appear, then type Device File in it and Device File Explorer will appear in search result and you can click it.

    Then you can navigate to folder which you want to push your file in it. Right click on that folder and select upload(or press Ctrl+Shift+O). Select file you want to upload and it will upload file to desired location.

    Push file using adb.exe:

    In Android 6.0+, you should use same process but your android application cannot access files which pushed inside SDCARD using DDMS File Explorer. It is the same if you try commands like this:

    adb push myfile.txt /mnt/sdcard/myfile.txt
    

    If you face EACCES (Permission denied) exception when you try to read file inside your application, it means you have no access to files inside external storage, since it requires a dangerous permission.

    For this situation, you need to request granting access manually using new permission system in Android 6.0 and upper version. For details you can have a look in android tutorial and this link.

    Solution for old android studio version:

    If you want to do it using graphical interface you can follow this inside android studio menus:

    Tools --> Android --> Android Device Monitor

    Afterward, Android Device Monitor(DDMS) window will open and you can upload files using File Explorer. You can select an address like /mnt/sdcard and then push your file into sdcard.

    0 讨论(0)
  • 2020-12-23 16:13

    adb push [file path on your computer] [file path on your mobile]

    0 讨论(0)
  • 2020-12-23 16:15

    Open command prompt and give the platform-tools path of the sdk. Eg:- C:\Android\sdk\platform-tools> Then type 'adb push' command like below,

    C:\Android\sdk\platform-tools>adb push C:\MyFiles\fileName.txt /sdcard/fileName.txt

    This command push the file to the root folder of the emulator.

    0 讨论(0)
  • 2020-12-23 16:16

    refer johnml1135 answer, but not fully work.

    after self investigate, work now:

    as official say:

    添加文件

    将任意文件拖动到模拟器屏幕上。文件将保存到 /sdcard/Download 目录中。使用适合 API 级别的方法导航到文件。例如,对于 API 22,导航路径为:Settings > Device:Storage & USB > Internal Storage > Explore(虚拟 SD 卡)。

    and use Drag and Drop actually worked, but use android self installed app Download, then you can NOT find the copied file, for not exist so called /sdcard/Download folder.

    finally using other file manager app, like

    ES File Explorer

    then can see the really path is

    /storage/emulated/0/Download/

    which contains the copied files, like

    /storage/emulated/0/Download/chenhongyu_lixiangsanxun.mp3

    after drag and drop more mp3 files:

    0 讨论(0)
  • 2020-12-23 16:19

    Android Device monitor is no longer available in android studio.

    If you are using android studio 3.0 and above.

    1. Go to "Device File Explorer" which is on the bottom right of android studio.
    2. If you have more than one device connected, select the device you want from the drop-down list on top.
    3. mnt>sdcard is the location for SD card on the emulator.
    4. Right click on the folder and click Upload. See the image below.

    Note: You can upload folder as well not just individual files.

    0 讨论(0)
提交回复
热议问题