Java 安卓SD卡路径概要
我有一个有点奇怪的问题:这次一切正常,但我不明白为什么 这样就可以安装多个sd卡了。所有内容都将装入Java 安卓SD卡路径概要,java,android,file-io,Java,Android,File Io,我有一个有点奇怪的问题:这次一切正常,但我不明白为什么 这样就可以安装多个sd卡了。所有内容都将装入/mnt目录。(这是真的吗?) 在我的设备上,只有一个sd卡安装在/mnt/sdcard上。在我的应用程序中,我从中打开文件。我正在使用下一个代码: private void open() { // get file extension String extension = ""; int dotIndex = downloadedFile.
/mnt
目录。(这是真的吗?)
在我的设备上,只有一个sd卡安装在/mnt/sdcard
上。在我的应用程序中,我从中打开文件。我正在使用下一个代码:
private void open() {
// get file extension
String extension = "";
int dotIndex = downloadedFile.lastIndexOf('.');
if (dotIndex != -1) {
extension = downloadedFile.substring(dotIndex + 1, downloadedFile.length());
}
// create an intent
Intent intent = new Intent(android.content.Intent.ACTION_VIEW);
Uri data = Uri.fromFile(new File(downloadedFile));
String type = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension);
if (type == null || type.length() == 0) {
// if there is no acceptable mime type
type = "application/octet-stream";
}
intent.setDataAndType(data, type);
// get the list of the activities which can open the file
List resolvers = context.getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
if (resolvers.isEmpty()) {
(new AlertDialog.Builder(context)
.setMessage(R.string.AttachmentUnknownFileType)
.setNeutralButton(R.string.NeutralButtonText, null)
.create()).show();
} else {
context.startActivity(intent);
}
}
实际上downloaddedfile
变量的值类似于file:///sdcard/mydir/myfile.txt
。但代码是有效的。为什么?Android如何理解/sdcard/..
与/mnt/sdcard/..
相同的内容
主要问题:如果sd卡将被安装到其他目录(对于exmaple,/mnt/other sd/
甚至/media/sd
),会发生什么情况?如果要挂载多张sd卡怎么办:android如何理解要使用哪张卡
谢谢你的帮助!祝你有愉快的一天 很简单,安卓在手机开机时通过设置文件配置挂载,因此如果有mor SD卡,安卓只会选择其中一个设置为 /SD卡/ 因此,当挂载设置更改时,您的代码完全无用,您只能希望这些设置不会被更改。
每一家生产安卓智能手机的公司都使用“SD卡”路径,甚至像use这样的定制ROM也使用它文件夹的不同路径如何?为什么路径
file:///sdcard/
与/mnt/sdcard
相同吗?