0

画像を新しい場所に保存し、MediaScanner を使用してギャラリーを更新すると、すべて問題なく、サムネイルと画像が適切に更新されます。

しかし、画像を既存の場所に保存してから MediaScanner を使用すると、「新しい」サムネイルのみが更新されません。(ファイルは上書きされますが)。

それを解決する方法は?

これが私のコードです:

File file = new File(SDCARD_PATH, filename);

try {
    FileOutputStream out = new FileOutputStream(file);
    bmp.compress(format, BEST_IMAGE_QUALITY, out);
}catch (FileNotFoundException e) {

}

//refreshing single file using media scanner, no need to paste
4

2 に答える 2

0

新しい画像をファイルシステムに保存する前に、「古い」画像を削除しようとしましたか?そのようです:

File file = new File(SDCARD_PATH, filename);

try {
    // Delete the "old" file.
    if (file.exists()) {
        file.delete();
    }

    FileOutputStream out = new FileOutputStream(file);
    bmp.compress(format, BEST_IMAGE_QUALITY, out);
}catch (FileNotFoundException e) {
}catch (SecurityException e) {
}
于 2011-10-18T13:18:24.570 に答える