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
.
It's pretty easy, internal storage is unavailable on non-rooted devices. So as was mentioned in bwt answer you just need to push your data to sdcard :
adb push somefile /sdcard/somefile
With retrieving files from your filesystem you'll also have few problems. But with the case of pulling a database from a debug application - you'll just need to change file permission via chmod
.
Here you have a useful link - XDA guys about adb
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With