简体   繁体   English

Android访问获取外部目录

[英]Android Accessing get external directory

Now, I am working on data transmission using bluetooth. 现在,我正在使用蓝牙进行数据传输。 I have such problem in selecting file in SD card/ internal storage. 我在选择SD卡/内部存储器中的文件时遇到此类问题。

  1. I am already put permission in manifest : 我已经在清单中放了权限:

  2. I am using this command to get access the file File sdCard = Environment.getExternalStorageDirectory(); 我正在使用此命令来访问文件File sdCard = Environment.getExternalStorageDirectory();。

  3. But when I am check using this command if (sdCard.canRead()) , it can't read the path. 但是当我使用(sdCard.canRead())检查此命令时,它无法读取路径。

Anyone have the solution within my problem? 任何人都可以解决我的问题吗? Thanks anyway 不管怎么说,还是要谢谢你

The Android Dev resources has a good guide on this. Android Dev资源对此有很好的指导。

Assuming you have all the correct permissions, you could be facing issues where the storage is not mounted or there is not enough space. 假设您拥有所有正确的权限,则可能会遇到未装载存储或空间不足的问题。 The guide explains how to check the state of the External Storage Dir, etc. 该指南说明了如何检查外部存储目录等的状态。

Did you add the following line to the AndroidManifest? 您是否将以下行添加到AndroidManifest?

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

From android SDK version 4, you need to add that line to access external storage by your app. 从android SDK版本4开始,您需要添加该行以通过您的应用访问外部存储。

Some of other issues are, (Check whether phone detects the SD card) 其他一些问题是,(检查手机是否检测到SD卡)

  • SD Card is Not Clean SD卡不干净
  • Battery Voltage 电池电压
  • Card Slot is Squeezed 卡槽被挤压
  • Metal Wires in the Card Slot Get Rusty and Twisted 卡插槽中的金属线会生锈并扭曲
  • Malware Invade SD Card 恶意软件入侵SD卡
  • SD Card is not Formatted Properly SD卡未正确格式化
  • SD Card is Broken SD卡坏了
  • The Phone Breakdown 电话故障

problem solved. 问题解决了。 The problem is related with new android SDK. 问题与新的android SDK有关。 We need to add additional permission. 我们需要添加其他权限。

Thanks everyone. 感谢大家。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM