【发布时间】:2011-11-16 18:41:39
【问题描述】:
在深入研究了有关如何将自定义文件与我的应用程序关联的数十个问题之后,我要问一个明确的问题: 如何使用 FileOutputStream 添加 mime 类型?
我将尝试解释: 我的应用程序编写了“lorenzoff”文件,这是错误的,但可以说没有任何扩展名。我知道 Android 使用 mime 类型,好的,我明白了,我将此意图过滤器添加到我的清单中
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:host="" android:scheme="file" android:mimeType="application/wtf" />
</intent-filter>
现在,我想用它们的内容创建我的新文件,比如说
DataOutputStream os = new DataOutputStream(new FileOutputStream("lorenzoff"));
os.writeInt(1);
os.writeInt(2);
os.writeInt(3);
os.close();
使用文件系统浏览应用程序 (Astro) 检查新创建的文件,我可以看到它没有 mime 类型,而且我们到了,我无法通过我的应用程序 VIEW 它(它有没有关联)。
问题:如何编写 mime 类型以便我可以读取“application/wtf”来检查文件属性?
提前致谢
【问题讨论】:
标签: android mime-types add