#获取系统图片遇到的坑--Cursor空指针异常
来源:互联网 发布:学而知之什么意思 编辑:程序博客网 时间:2024/06/05 17:11
获取系统图片遇到的坑–Cursor空指针异常
Cursor 空指针异常:
小米N2测试的时候报Cursor空指针异常的错误
Uri photoUri = data.getData(); Uri photoUri = data.getData(); if (null == photoUri) { return; } //获取照片路径 String[] filePathColumn = {MediaStore.Audio.Media.DATA}; Cursor cursor = getContentResolver().query(photoUri, filePathColumn, null, null, null); cursor.moveToFirst(); mPhotoPath = cursor.getString(cursor.getColumnIndex(filePathColumn[0])); cursor.close();
getContentResolver().query(photoUri, filePathColumn, null, null, null);
返回未空,修改如下,做判断
if (cursor != null) { cursor.moveToFirst(); int columnIndex = cursor.getColumnIndex(filePathColumn[0]); String picturePath = cursor.getString(columnIndex); cursor.close(); mPhotoPath = picturePath; } else { mPhotoPath = photoUri.getPath(); }
阅读全文
0 0
- #获取系统图片遇到的坑--Cursor空指针异常
- android 中遇到的空指针异常
- Eclipse Plugin 获取图片资源返回空指针异常错误的解决办法。
- 用List的时候遇到的一个空指针异常
- 安卓开发里面可能遇到的空指针异常
- Android--关于Cursor空指针的问题
- Android下findViewById遇到空指针异常
- WebSocket获取httpSession空指针异常的解决办法
- 自定义控件获取报空指针异常
- ViewHolder模式获取控件空指针异常
- 空指针异常的解决
- 很蛋疼的空指针异常
- 空指针异常的原因
- 空指针异常学到的
- Jsp的空指针异常
- 空指针异常的解决
- android3.2系统removeHeadView空指针异常
- Java中遇到的报错信息为:空指针异常的情况
- 2.3 类型转换运算
- UNIX网络编程——socket的keep-alive
- cannot be registered to your development team. Change your bundle identifier to a unique string to t
- Mvc Pager 分页
- chrome最新版本下载
- #获取系统图片遇到的坑--Cursor空指针异常
- 第 4 章 垃圾回收概念与算法
- 正则表达式
- 《C#2.0锐利体验系列课程》第一讲——泛型
- 达尔文op2官方代码解读(三)之信号处理
- 魔鬼经济学
- 图论第二次课
- 01-商城购物车练习
- 绘图和可视化