访问外部存储在文件选择器 [英] Access external storage in File Chooser
问题描述
我想实现一个文件选择。我使用的<一个href="https://github.com/mburman/Android-File-Explore/blob/master/FileExplore/src/com/mburman/fileexplore/FileExplore.java"相对=nofollow> Android文件浏览在我的应用程序文件选择。当我运行的应用程序,它为我的内部存储,并返回我的文件路径,但它并没有显示出外部存储在所有。
I am trying to implement a File Chooser. I am using Android File Explore for file chooser in my app. When I run the app, it shows me Internal storage and returns me the file path, but it doesn't show External Storage at all.
这是我的AndroidManifest.xml文件。
This is my AndroidManifest.xml file.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.unicloud.mittal" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
<uses-permission android:name="android.permission.MANAGE_DOCUMENTS" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:logo="@drawable/ic_launcher"
android:theme="@style/AppTheme" >
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<activity
android:name=".Splash"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".loginWithGooglePlus"
android:label="@string/app_name"
android:logo="@drawable/ic_launcher" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".FileExplore"
android:label="Pick a file"
android:permission="android.permission.MANAGE_DOCUMENTS" >
<intent-filter>
<action android:name="android.content.action.DOCUMENTS_PROVIDER" />
</intent-filter>
</activity>
</application>
</manifest>
我哪里做错了吗?
Where I am doing wrong?
推荐答案
在你使用上面的github上的链接<一个href="http://developer.android.com/reference/android/os/Environment.html#getExternalStorageDirectory()"相对=nofollow> Environment.getExternalStorageDirectory() API,它工作正常。我想你是误会了使用该API的。此API总是返回主外部存储目录。下面的解释可以帮助你:
In the above github link you are using Environment.getExternalStorageDirectory() API which is working as expected. I think you misunderstood the use of this API. This API will always return the primary external storage directory. Below explanation may help you:
首先,是什么内部存储,外部存储(又名主要外部存储)和辅助外部存储?
内部存储:是存储,是不是由用户可访问的,除了通过安装的应用程序(或铲除他们的设备)。例如:数据/数据/ app_packageName
Internal Storage: is storage that is not accessible by the user, except via installed apps (or by rooting their device). Example: data/data/app_packageName
主要外部存储:在建的共享存储,这是通过插入USB电缆和安装它作为一个驱动器主机上的用户可以访问。例如:当我们说的Nexus 5 32 GB
Primary External Storage: In built shared storage which is "accessible by the user by plugging in a USB cable and mounting it as a drive on a host computer". Example: When we say Nexus 5 32 GB.
辅助外部存储:可移动存储。示例:SD卡。
Secondary External Storage: Removable storage. Example: SD Card.
现在,下一个问题。如何访问棒棒堂的SD卡? 要访问SD卡的Android推出新的存储访问架构在奇巧。
Now next question. How to access SD card in Lollipop? To access SD card Android introduced new Storage Access Framework in KitKat.
下面是一个答案解释它精美: http://stackoverflow.com/a/26765884/631803
Here is one answer explained it beautifully: http://stackoverflow.com/a/26765884/631803
这篇关于访问外部存储在文件选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!