//android把图片文件添加到相册

ContentResolver localContentResolver = getContentResolver();
ContentValues localContentValues = getImageContentValues(MonitorActivity.this, file, System.currentTimeMillis());
localContentResolver.insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, localContentValues); Intent localIntent = new Intent("android.intent.action.MEDIA_SCANNER_SCAN_FILE");
final Uri localUri = Uri.fromFile(fileshare);
localIntent.setData(localUri);
sendBroadcast(localIntent);

public static ContentValues getImageContentValues(Context paramContext, File paramFile, long paramLong)
{
  ContentValues localContentValues = new ContentValues();
  localContentValues.put("title", paramFile.getName());
  localContentValues.put("_display_name", paramFile.getName());
  localContentValues.put("mime_type", "image/jpeg");
  localContentValues.put("datetaken", Long.valueOf(paramLong));
  localContentValues.put("date_modified", Long.valueOf(paramLong));
  localContentValues.put("date_added", Long.valueOf(paramLong));
  localContentValues.put("orientation", Integer.valueOf(0));
  localContentValues.put("_data", paramFile.getAbsolutePath());
  localContentValues.put("_size", Long.valueOf(paramFile.length()));
  return localContentValues;
}


  

android把视频文件添加到相册

//是否添加到相册
ContentResolver localContentResolver = this.getContentResolver();
ContentValues localContentValues = getVideoContentValues(this, file, System.currentTimeMillis());
Uri localUri = localContentResolver.insert(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, localContentValues);

public static ContentValues getVideoContentValues(Context paramContext, File paramFile, long paramLong)
{
  ContentValues localContentValues = new ContentValues();
  localContentValues.put("title", paramFile.getName());
  localContentValues.put("_display_name", paramFile.getName());
  localContentValues.put("mime_type", "video/3gp");
  localContentValues.put("datetaken", Long.valueOf(paramLong));
  localContentValues.put("date_modified", Long.valueOf(paramLong));
  localContentValues.put("date_added", Long.valueOf(paramLong));
  localContentValues.put("_data", paramFile.getAbsolutePath());
  localContentValues.put("_size", Long.valueOf(paramFile.length()));
  return localContentValues;
}

android把图片 视频 保存到相册的更多相关文章

  1. iOSQuartz2D-04-手动剪裁图片并保存到相册

    实现效果 操作步骤 绘制一个矩形框,弹出一个alertView,提示是否保存图片 点击"是",将图片保存到相册 在相册中查看保存的图片 效果图 实现思路 在控制器的view上添加一 ...

  2. Android——将图片加入到系统相册里面

    Adnroid中保存图片的方法可能有如下两种: 第一种是自己写方法,如下代码: public static File saveImage(Bitmap bmp) { File appDir = new ...

  3. [Android] 压缩图片并保存

    不难,但用的时候有时候突然会想不起来..记录一下吧 原文地址请保留http://www.cnblogs.com/rossoneri/p/3995096.html 先加权限 <uses-permi ...

  4. Swift中获取相册图片与保存到相册

    关于这个网上目前位置记录的资料比较少,记录一下这个坑 获取相册图片 1: var iPC = UIImagePickerController() 2: iPC.sourceType = UIImage ...

  5. js 生成手机图片并保存到相册

    1.注意权限问题 2.调用HTML5+api 3.优化显示 4.注意兼容ios.Android

  6. 微信小程序生成分享图片,保存到本地

    1.页面 <canvas canvas-id="shareCanvas" style="width:600px;height:900px">< ...

  7. [RN] React Native 图片保存到相册(支持 Android 和 ios)

    React Native 图片保存到相册(支持 Android 和 ios) 原理: IOS用 RN自带的 CameraRoll, Android 使用 不成功,需要 react-native-fs  ...

  8. Android将图片保存到相册并及时看到

    Android中将图片保存到SD卡中,相册里不会及时出现这张图片,因为没有及时更新其索引,一般需要开机几次.当然我们可以手动更新其索引. 1,首先将文件保存到SD卡中. String filePath ...

  9. Android--解决图片保存到相册显示1970年1月1日 8:00的问题

    import android.content.Context; import android.content.Intent; import android.database.Cursor; impor ...

随机推荐

  1. HDU 5834 Magic boy Bi Luo with his excited tree

    树形dp. 先dfs一次处理子树上的最优解,记录一下回到这个点和不回到这个点的最优解. 然后从上到下可以推出所有答案.细节较多,很容易写错. #pragma comment(linker, " ...

  2. 《Windows编程循序渐进》——MFC封装机制详解

    单文档

  3. spring-security 配置文件

    转自:spring-security学习笔记--配置文件 <?xml version="1.0" encoding="UTF-8"?> <be ...

  4. el表达式跟ognl表达式的区别

    :  EL表达式 单纯在jsp页面中出现,是在四个作用域中取值,page,request,session,application. 如果在struts环境中,它除了有在上面的四个作用域的取值功能外,还 ...

  5. 用户id有则更新,无则添加 使用replace into (代替 insert into)

    app登录成功后,调用后台,更新channel_id public function set_pushchannel($device,$channelid,$iv='' ) $sql = " ...

  6. Mysql表名区分大小写

    mysql数据库在windows服务器上表名和字段名均不区分大小写, 但在linux服务器上表名默认是区分大小写的,可在/etc/my.cnf文件中的[mysqld]下面加上一条配置 lower_ca ...

  7. Unity5系列资源管理AssetBundle——更新实现

    前面我们研究了AssetBundle的打包与加载,现在我们来了解下如何在项目中根据版本号更新内容. 最最重要的一点,细心的朋友应该看到了在加载AssetBundle的MrcAssetManager类中 ...

  8. OMCS开发手册(03) -- 多媒体服务器

    前面我们已经详细介绍了基于OMCS开发网络多媒体应用的客户端程序所必需掌握的内容,现在我们来看一下OMCS服务端的开发.对于使用者而言,OMCS的服务端就非常简单了,只要实现一个用户验证的接口,挂接到 ...

  9. 转载-ACPI的知识

    ACPI – the Advanced Configuration & Power Interface. ACPI是OS,BIOS和硬件之间的抽象层.它允许OS和平台独立的发展,比如新的OS可 ...

  10. 超界文字滚动 (id和类型两种实现方式)

    //根据元素id <!DOCTYPE html><html lang="zh-CN"><head> <meta charset=" ...