Till Android Lollypop emulators, we can access the file explorer folders. If the emulator is created with marshmallow or higher, we cant access the file explorer. May be this is bug from API level 24+.
A temporary solution, which worked at least for my needs, was to install file manager .apk (I used Astro file manager .apk) - just drag/drop .apk to emulator window. Another very useful utility - ImDisk - which let's mount sdcard .img of virtual device. If you mount it as readonly ejectable device, you can have realtime access to virtual device file system
This is bug in Android Device Monitor and has been reported to google.
According to Post this thread will be updated when the patch is released.
A workaround using the adb
command line tool:
root@mypc ~ $ adb kill-server
root@mypc ~ $ adb start-server
root@mypc ~ $ adb root
Now you can browse through the file system using the linux ls
command:
root@mypc ~ $ adb shell ls -all /
total 3688
drwxr-xr-x 15 root root 0 2017-04-21 11:11 .
drwxr-xr-x 15 root root 0 2017-04-21 11:11 ..
drwxr-xr-x 29 root root 0 2017-04-21 11:11 acct
drwxrwx--- 6 system cache 4096 2017-01-06 12:11 cache
lrwxrwxrwx 1 root root 13 1970-01-01 01:00 charger -> /sbin/healthd
...
-rw-r--r-- 1 root root 4853 1970-01-01 01:00 ueventd.rc
lrwxrwxrwx 1 root root 14 1970-01-01 01:00 vendor -> /system/vendor
Another temporary solution is to use the adb shell
First, copy the database to the sdcard
./adb shell run-as com.yourapplication cp /data/data/com.yourapplication/databases/yourFileName.db /sdcard
Then, pull the database file to your computer
./adb pull /sdcard/yourFileName.db /Users/yourUserName/Desktop
It probably has to do with the new Android folder permissions. As posted in another answer you can use:
root@mypc ~ $ adb root
to gain root access to your emulator (no need to restart the adb). Then you can see all the folders on the device with DDMS file explorer or through the shell. The other option is to wait for a new file explorer that was promised in version 2.4 of Android Studio.
If you need to refresh the gallery after that as I did you could use:
root@mypc ~ $ adb shell "am broadcast -a android.intent.action.MEDIA_MOUNTED -d file:///mnt/sdcard"
This will simulate mounting of a SD card which will trigger media rescan.
Its an alternative way.
Create a bat file configure the APP_NAME, Example (com.example.com)
DESTINATION_FOLDER (myProjectFiles)
cd "C:\Users\USERNAME\AppData\Local\Android\sdk\platform-tools\"
adb shell run-as APP_NAME rm -R /sdcard/DESTINATION_FOLDER
adb shell run-as APP_NAME cp -R cache/ /sdcard/DESTINATION_FOLDER
rmdir C:\Users\USERNAME\Documents\DESTINATION_FOLDER /s /q
adb pull /sdcard/DESTINATION_FOLDER C:\Users\USERNAME\Documents\
timeout 5
After Configuring your bat file run it by double clicking . it will do the rest
I also faced same problem in the Android Device Monitor.
The emulator we use is very high level like Nougat 24+, so to over come this, we have to just run emulator in level level ie, Lollipop 22
As another workaround, I use fileList()
to get all the files in the Files
folder of my app and log it to logcat:
String[] files = fileList();
// log files, or add a watch in the debugger...
It is also possible to get the files and directories in your cache
folder as well:
String[] filesInCache = getCacheDir().list();
Or
File[] filesInCache = getCacheDir().listFiles();
I had this problem with Api 27 (Oreo). I tried to create emulator with Lollipop but same as with Oreo. Device monitor was empty.
After restarting computer everything was normal. This is solution for many problems that comes with Android Studio. First check this, than everything else.
Try some methods:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.