發現程序把圖片保存到sdcard後,在相冊裏面找不到,只有在sdcard從新裝載後會出現圖片;對象
原來圖片保存到本地後,須要通知相冊,加上以下代碼就行了:圖片
Uri localUri = Uri.fromFile(imageFile);ip
Intent localIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, localUri);get
sendBroadcast(localIntent);io
imageFile是圖片的File對象;ast
或者程序
ContentValues localContentValues = new ContentValues();im
localContentValues.put("_data", imageFile.toString());di
localContentValues.put("description", "save image ---");cas
localContentValues.put("mime_type", "image/jpeg");
ContentResolver localContentResolver = getContentResolver();
Uri localUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
localContentResolver.insert(localUri, localContentValues);