我在学习android写入文件时遇到了这样一个问题,我想将一个已经存在于项目资源文件中的文件写入SD卡中,
Resources resources=getBaseContext().getResources();
is=resources.openRawResource(imageAdapter.imageIDs[index]);
其中imageAdapter.imageIDs[index]是资源文件的索引//取得资源文件的名称
String entryName=resources.getResourceEntryName(imageAdapter.imageIDs[index]);
但是不知道怎么样取得资源文件的后缀名,因为我想在这句代码中使用
File newFile=new File(root,"123.jpg");
我不想在代码中将文件名限制死,各位大虾帮帮忙,我弄了一个下午了还是没找到用什么方法来实现
Resources resources=getBaseContext().getResources();
is=resources.openRawResource(imageAdapter.imageIDs[index]);
其中imageAdapter.imageIDs[index]是资源文件的索引//取得资源文件的名称
String entryName=resources.getResourceEntryName(imageAdapter.imageIDs[index]);
但是不知道怎么样取得资源文件的后缀名,因为我想在这句代码中使用
File newFile=new File(root,"123.jpg");
我不想在代码中将文件名限制死,各位大虾帮帮忙,我弄了一个下午了还是没找到用什么方法来实现
解决方案 »
- 下源码报Unable to look up android.git.kernel.org(port 9418) Name or service not know
- 改变button的位置和大小?
- 预测APP获奖名单第二波开始啦!~~奖品更给力!
- 跪求 android 连接 webService
- 关于不同尺寸的虚拟机分辨率的问题
- 有关CursorTreeAdapter类的几个事件的触发顺序和触发几次
- openfire添加好友一次验证通过
- 应用点击home键的问题
- 不知道才是最难的,求大神帮忙
- 安卓电视抓取屏幕的想法设计
- 50RMB求SAX解析XML网站代码问题的解答
- 关于android全局异常处理的询问询问
class MusicFilter implements FilenameFilter
{
public boolean accept(File dir, String name)
{
//这里还可以设置其他格式的音乐文件
return (name.endsWith(".mp3"));
}
}
MimeType请参考http://en.wikipedia.org/wiki/MIME_type#List_of_common_media_types
上面少写了一个字:string.subString(string.lastIndexOf("."))
对于图片资源一样适用。