目前有个项目需要写文件到sd卡,以下代码在4.0上可以运行,但是在2.3上就一直提示no such file or directory:File file=new File(path+"123.xls");
if(!file.getParentFile().exists())
{
file.getParentFile().mkdirs();
}
if(file.exists())
{
file.delete();
file.createNewFile();
}
else{
file.createNewFile();
}权限已经加了,不属于权限问题。不管是分开创建目录和文件还是一起创建,都是这个问题。貌似是mkdirs()一直返回false,即创建不成功,可能的原因是什么呢??
if(!file.getParentFile().exists())
{
file.getParentFile().mkdirs();
}
if(file.exists())
{
file.delete();
file.createNewFile();
}
else{
file.createNewFile();
}权限已经加了,不属于权限问题。不管是分开创建目录和文件还是一起创建,都是这个问题。貌似是mkdirs()一直返回false,即创建不成功,可能的原因是什么呢??
解决方案 »
- 请问一下android socket用TCP方式,client端如何监听服务器发送来的数据?
- android mysql
- Android学习
- launchMode设置为singletask的一点疑问,标题要长。。。
- 小菜请教高手:在android中怎么用代码将麦克风的音量设为静音
- 转行android游戏开发如何?
- RSS问题,调用开源syndication 操作超时。。
- The method screenshot(int, int) is undefined for the type Surface
- 安卓开发资料推荐?
- 新人求助,在线等了,android下拉效果的问题。
- android 判断获取相册图片是横向还是纵向
- android 多点触摸 问题
String mSavePath = "";
mSavePath = "/data/data/" + getPackageName()+"/images";
File fileDir = null;
if (fileDir == null) {
fileDir = new File(mSavePath);
if (!fileDir.exists()) {
fileDir.mkdir();
}
}