今天用了这段代码去修改了一张图片的内容,在XP的文件管理器中打开此图片时,已无法预览图片。
可是,为什么用手机相册查看时,还能看到原图?是不是读的缓存?要怎么样清除对应图片文件的缓存文件?
public void UpdatePhoto(String photoPath) throws IOException
{
String tmpMsg = String.valueOf((Math.random() + 1) * 1000000);
try
{
// File tmp = File.createTempFile("tmp", null);
// tmp.deleteOnExit();
RandomAccessFile raf = new RandomAccessFile(photoPath, "rw");
long rafLeng = raf.length();
int tmpMsgLeng = tmpMsg.length();
// 创建一个临时文件来保存插入点后的数据
// FileOutputStream tmpOut = new FileOutputStream(tmp);
// FileInputStream tmpIn = new FileInputStream(tmp);
// ----------下面代码插入内容----------
// 把文件记录指针定位到0位置
for (long i = 0; i < rafLeng / tmpMsgLeng - 1; i++)
{
raf.seek(i * tmpMsgLeng);
// 追加需要插入的内容
raf.write(tmpMsg.getBytes());
}
raf.close();
}
}
在手机卡上找到个文件夹:Android\data\com.cooliris.media\cache\hires-image-cache,
这里竟然能找到以前所有被删除掉的照片,这时什么情况?
而且其文件名都是数字,请问原文件名与这个文件夹里对应的文件名如果联系起来?
如果能有办法联系起来,就可以用代码来删除里面对应的文件了。
------解决方案--------------------
在手机卡上找到个文件夹:Android\data\com.cooliris.media\cache\hires-image-cache,
这里竟然能找到以前所有被删除掉的照片,这时什么情况?
而且其文件名都是数字,请问原文件名与这个文件夹里对应的文件名如果联系起来?
如果能有办法联系起来,就可以用代码来删除里面对应的文件了。
我也不会,帮你顶一下吧。。。
------解决方案--------------------
有缓存。 缓存的是图片缩略图
public static final class Images {
public interface ImageColumns extends MediaColumns {
/**
* The description of the image
* <P>Type: TEXT</P>
*/
public static final String DESCRIPTION = "description";
/**
* The picasa id of the image
* <P>Type: TEXT</P>
*/
public static final String PICASA_ID = "picasa_id";
/**
* Whether the video should be published as public or private
* <P>Type: INTEGER</P>
*/
public static final String IS_PRIVATE = "isprivate";
/**
* The latitude where the image was captured.
* <P>Type: DOUBLE</P>
*/
public static final String LATITUDE = "latitude";
/**
* The longitude where the image was captured.
* <P>Type: DOUBLE</P>
*/
public static final String LONGITUDE = "longitude";
/**
* The date & time that the image was taken in units
* of milliseconds since jan 1, 1970.
* <P>Type: INTEGER</P>
*/
public static final String DATE_TAKEN = "datetaken";
/**
* The orientation for the image expressed as degrees.