android内部存储 file,来自android内部存储的file.delete()返回false

我有一种方法从url下载图像并将其保存在内部存储的文件夹中

public void saveDynamicImage(String url,String fileName, String folderName) {

InputStream iStream;

BufferedInputStream buffInputStream;

ByteArrayBuffer byteArray = null;

try {

HttpGet httpGet = new HttpGet(url);

HttpClient httpClient = new DefaultHttpClient();

HttpResponse httpResponse = httpClient.execute(httpGet);

iStream = httpResponse.getEntity().getContent();

buffInputStream = new BufferedInputStream(iStream, 8 * 1024);

byteArray = new ByteArrayBuffer(50);

int current = 0;

while ((current = buffInputStream.read()) != -1) {

byteArray.append((byte) current);

}

} catch (ClientProtocolException e1) {

} catch (IOException e1) {

}

File dynamicImageDir = context.getDir(AppConstants.DYNAMIC_IMAGE, Context.MODE_PRIVATE);

File appNamefileDir = new File(dynamicImageDir, BaseActivity.appDataStore.getAppName());

appNamefileDir.mkdirs();

File controlNameDir = new File(appNamefileDir, folderName);

controlNameDir.mkdirs();

File file = new File(controlNameDir, fileName);

try {

FileOutputStream outputStream = new FileOutputStream(file);

outputStream.write(byteArray.toByteArray());

outputStream.close();

System.out.println("DynamicImage saving over!..");

} catch (FileNotFoundException e) {

} catch (IOException e) {

}

}

我想在一个时间点删除整个目录.我删除整个目录的方法是

public void deleteDynamicImage() throws NullPointerException,FileNotFoundException {

File rootDirectory = context.getDir(AppConstants.DYNAMIC_IMAGE, Context.MODE_WORLD_WRITEABLE);

boolean status = rootDirectory.delete();

Log.e("", "delete : "+status);

}

我的状态为“假”.文件已创建且工作正常.只有删除的问题.有什么我想念的吗?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值