我需要从内部存储中删除文件。 以下代码用于创建文件。
Picasso.with(mContext).load(imageurl).into(new Target() {
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
try {
String root = Environment.getExternalStorageDirectory().toString();
File myDir = new File(root + "/Omoto Images");
if (!myDir.exists()) {
myDir.mkdirs();
}
String name = imagename;
myDir = new File(myDir, name);
FileOutputStream out = new FileOutputStream(myDir);
bitmap.compress(Bitmap.CompressFormat.JPEG, 90, out);
out.flush();
out.close();
} catch (Exception e) {
}
}
@Override
public void onBitmapFailed(Drawable errorDrawable) {
}
@Override
public void onPrepareLoad(Drawable placeHolderDrawable) {
}
});
以下代码用于删除
String root = Environment.getExternalStorageDirectory().toString();
File myDir = new File(root + "/Omoto Images");
myDir.delete();
但删除无效