In my application, I create files and write them to the Sdcard. My created files show properly in DDMS, and in windows explorer when I mount my Samsung Galaxy as a USB device. But, they do not show in Windows explorer on my Acer Iconia Tab A500, when it is connected by USB. I assume this is due to some difference in 3.0? Do I need to create my files differently in 3.0 so that they show in Windows by usb?
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
Thought I'd post a new answer, because the current accepted answer doesn't work for anything after KitKat.
Solution provided by darrenp here.
This may be from way out in left field. I am new to Android developing and was having the same problem: I save a file to the sd card, and I don't even SEE the ANDROID directory when I hook up my phone to my windows computer to look at the phone. On a whim, I went to Developer options (that thing you get by tapping the build number 7 times) to configure developer options and I turned "Developer options" off. I think somewhere in the mayhem I toggled "USB debugging" on and off as well. Had to do the seven taps thing again. Now I see the ANDROID directory and the files I saved under ANDROID/data/com.blahblah.blahblah/files. Go figure. Maybe a version of "reboot." Random, I know, but it worked for me ;-/
How are you determining the location of the SD Card?
It sounds like you are assuming the SD Card is always mounted at
/mnt/sdcard
. You should absolutely never hardcode paths in Android since each implementation may mount the SD card in a different location. Rather, you should be usinggetExternalStorageDirectory()
to determine where the SD card is mounted, and build your path from that.Also found this problem on a Nexus 7. If you device connects to your PC with MTP (the preferred USB connection protocol post honeycomb), when you create a file, the media scanner needs to be updated for it to be immediately visible in Windows Explorer.
Some devices update the media scanner automatically (Samsung S4), some do not (Nexus 7). After creating the new file on the SD card, to make sure the media scanner is updated make the following call.
Here is a really good post on the topic. Thanks go to the author for the explanation and code above. https://www.grokkingandroid.com/adding-files-to-androids-media-library-using-the-mediascanner/
On my Acer Iconia Tab, getExternalStorageDirectory actually points to an internal storage (considered as "shared", as opposed to the "private" inner storage), and is mounted as /mnt/sdcard. There is an alternative (and "true") external storage that goes on the SDcard at /mnt/external_sd. I'm not sure if there currently is a perfect method to get that path, though. Do you know which partition is mounted when you connect your Iconia Tab by USB ?
example of create read and write file sdcard.
}