CodePudding user response:
When save photos, can be in number of mm path joining together a storage date, and then delete the milliseconds and judgment when the current milliseconds isn't more than three days, if more than three days, deleted photosCodePudding user response:
Cursor photoCursor=mContext. GetContentResolver () query (
MediaStore. Images. Media EXTERNAL_CONTENT_URI,
Null, null, null, null);
Try {
While (photoCursor. MoveToNext ()) {
Photo Photo=new Photo ();
//photo path
String photoPath=photoCursor. Get String (photoCursor getColumnIndex (MediaStore. Images. Media. DATA));
//photo date
Long photoDate=photoCursor. GetLong (photoCursor getColumnIndexOrThrow (MediaStore. Images. Media. DATE_TAKEN));
//photo title
String photoTitle=photoCursor. Get String (photoCursor getColumnIndex (MediaStore. Images. Media. DISPLAY_NAME));
BitmapFactory. Options Options=new BitmapFactory. Options ();
Options. InJustDecodeBounds=true;
BitmapFactory. DecodeFile (photoPath, options);
//photo type
A String of photoType=options. OutMimeType;
//photo length
String photoLength=String. The valueOf (options. OutHeight);
//photo width
String photoWidth=String. The valueOf (options. OutWidth);
The File f=new File (photoPath);
FileInputStream fis=new FileInputStream (f);
//photo size
The float size=fis. Available ()/1000;
String photoSize=size + "KB";
PhotoCursor. Close ();
} the catch (Exception e) {
} the finally {
If (photoCursor!=null) photoCursor. Close ();
}