开发者

Possible to write files from Windows application directly to Android SD card?

开发者 https://www.devze.com 2023-03-12 02:02 出处:网络
I\'m looking for a way to write a file from a Windows application to an Android device SD card over a USB connection.To do this, I will need to obtain the drive letter of the SD card, and it\'s mount

I'm looking for a way to write a file from a Windows application to an Android device SD card over a USB connection. To do this, I will need to obtain the drive letter of the SD card, and it's mount point. My Windows application is written in C++, so I'm most hoping for a solution in C++. If not possible, perhaps there is a Java solution which can then be placed in a C++ wrapper to be called by my application's code.

I've searched around and come up with a few ideas but nothing seems to work yet. First, I came开发者_如何学C across Google's documentation on a method,Environment.getExternalStorageDirectory(), but my assumption is that since this is part of the Android SDK, it is only usable from an application residing on an Android device. Secondly, I came across some functions in Windows' native API (WinBase.h primarily), which provides a way of locating all drives and their corresponding letters, but even if I can get this information, I don't know how to determine which of these is the connected Android device's SD card.

Any help is appreciated!


I'm not a windows application expert but if you can use system calls in your C++ program to call adb.exe, then you can execute adb commands directly to the device.

For example if you can execute "adb.exe devices" you can get a list of all android devices currently attached to the computer. From there, you can use any adb commands to push files onto the device.

More information on the adb commands here: ADB wiki

What you're looking for is probably doing an adb devices in combination with adb push <your file> /sdcard/<file on sdcard>

Good luck!

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号