萬盛學電腦網

 萬盛學電腦網 >> 網絡編程 >> 安卓開發 >> Android刪除相冊

Android刪除相冊

  private void deleteLatestPhoto() {

  String[] projection = new String[] { MediaStore.Images.ImageColumns._ID,

  MediaStore.Images.ImageColumns.DATE_TAKEN };

  Cursor cursor = managedQuery(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, projection,

  null, null, MediaStore.Images.ImageColumns.DATE_TAKEN + " DESC");

  if (cursor != null) {

  cursor.moveToFirst();

  ContentResolver cr = mContext.getContentResolver();

  cr.delete(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,

  BaseColumns._ID + "=" + cursor.getString(0), null);

  }

  }

copyright © 萬盛學電腦網 all rights reserved