titanium mobile : delete remote image cache
http://developer.appcelerator.com/question/144356/urgent-how-to-clearreset-titanium-remote-image-cache-android
この辺。
http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.Filesystem
applicationCacheDirectory : StringREADONLY
Path to the application’s internal cache directory.
iosのほうはみんな違う書き方をしているけど昔は無かったのかな?
Ti.Filesystem.applicationCacheDirectory
ios : Applications/00000000-0000-0000-0000-AAAAAAAAAA/Library/Caches/
これなのでiosもあっています。
Libraryの下は
Cookies
Preferences
Caches
Private Documents
があって、Private Documents/databasename.sql という名前でsqliteが保存されていました。
画像は、普通に ハッシュ値.jpgの拡張子で保存されています。.をみて消している方は、ディレクトリを消しています。
特に問題ないと思いのですが、中に Cache.dbとかあります。手で全消ししても問題ないようです。
(十分テストが必要ですが)
androidはexternalのときの処理が必要。
androidの処理はbanzai mobileさんのやり方を利用させていただきます。
http://developer.appcelerator.com/question/144356/urgent-how-to-clearreset-titanium-remote-image-cache-android#answer-251819
ポイントは、/_tmp/remote-cache/ですね。
全消しはなんとなくあれなので、ファイルを消す処理(getFile以外)は、iosと共通で。
iosだけだとこんな感じ
if( dir.exists() ){
var files = dir.getDirectoryListing();
for( var i in files ){
if( files[i].match(/jpg|jpeg|png|gif/i)){
var f = Ti.Filesystem.getFile(Ti.Filesystem.applicationCacheDirectory, files[i]);
if( f.exists() ){
f.deleteFile();
}
}
}
return true;
}
実際は、起動時は全消し、タイミングをみて、古いものを消去でしょうか。
webview を使っているとCache.dbもモリモリ貯まって行くのでサイズをみて消した方が良さそうなので
定期的に全消しに変更したいと思います。
githubにあげました。
https://github.com/junichi-otake/titanium-lib
メモ:別の話。
http://developer.appcelerator.com/question/134926/ipad-app-rejected-ios-data-storage-guidelines