PIYO - Tech & Life -

Android

Android端末の写真をコードから削除する

Android触り始めました。さすがに初めてすぎて全然わかんない。 iOSと違ってAndroidでは公式ではないアプリが写真を削除できるらしいということでサンプルを書いてためしてみました。 下のコードでは

iOS、Androidの空き容量をコードで調べる

iOS NSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES); NSDictionary *dictionary = [[NSFileManager defaultManager] attributesOfFileSystemForPath:[paths lastObject] error:nil]; if (dictionary) { int GiB = 1024*1024*1024; float free = [[dictionary objectForKey: NSFileSystemFreeSize] floatValue]/GiB; float total = [[dictionary objectForKey: NSFileSystemSize] floatValue]/GiB; NSLog(@"Space: %.3f", free); NSLog(@"Total: %.3f", total); } Android ディレクトリのパスはいくつかとれますが、デバイスによって使われ方がどうも違うっぽい感じがしました。 写真のデータ置