If you attach android device to PC you can browse files and dirs. It is possible to get this directory using Environment.getExternalStorage()
. You can use it from your application and create accessible files and dirs. It works fine.
On my devices this path looks like /storage/emulated/0
and if i try adb push
to this directory i will get access denied error. Is it possible to copy files using adb
to the same folder as Windows Explorer does?
D:\...\tools>adb push ACCOUNTS.DB /storage/emulated/0
failed to copy 'ACCOUNTS.DB' to '/storage/emulated/0': Permission denied
58969 KB/s (606505 bytes in 0.010s)
I'm implementing automated import/export and i want files to be accessible without adb shell
in case anything will go wrong.
Currently using variable$EXTERNAL_STORAGE
as workaround, it works for both adb
and application.
Device: Asus Fonepad 7, Android 5.0, tried Genymotion Custom Tablet 6.0 - works.
Try to use /sdcard/
. Although it is strongly discouraged to do this in code. It seems to be the only way with adb :
$ adb push somefile /storage/emulated/0/somefile
[100%] /storage/emulated/0/somefile
adb: error: failed to copy 'somefile' to '/storage/emulated/0/somefile': Read-only file system
$ adb push somefile /sdcard/somefile
[100%] /sdcard/somefile
By the way, on my device they don't have the same value : Environment.getExternalStorage()
points to /storage/emulated/0/
while /sdcard
points to /storage/emulated/legacy
.