短信查询
来源:互联网 发布:mac圣诞限量套装2017 编辑:程序博客网 时间:2024/04/29 20:57
短信是记录在系统本地的mmssms.db表中的 /data/com.android.providers.telephony/databases中。
Cursor mCursor = managedQuery(Uri.parse("content://sms"), new String[] {"_id,address,date,read,status,type,body,count(address) as " + "totleCount from (select _id,substr(address,4) as address,date,read,status,type,body " + "from sms where address like \"+86%\" union select _id,address,date,read,status,type,body " + "from sms where address not like \"+86%\") r group by r.address order by r.date desc --"}, null, null, null);
这种是抛游标的方式,千万要小心处理,onPause()和onDestroy()要及时的关闭。
if (null != mCursor && !mCursor.isClosed()) { stopManagingCursor(mCursor); }
显示会话短信的Adapter可以使用ResourceCursorAdapter
public class FarmerAdapter extends ResourceCursorAdapter{ private Context mContext; public final class MessageHolder{ public ImageView img_icon; public ImageView newSms; public TextView nameTextView; public TextView unreadCount; public int count; public TextView countTextView; public TextView draft; public TextView date; public TextView message; public String phoneNumber; public String name; public String id;} public FarmerAdapter(Context context, int layout, Cursor c) { super(context, layout, c); this.mContext = context; } @Override public void bindView(View view, Context context, Cursor cursor) { /** * 这边是写的一些逻辑代码 */ } @Override public View newView(Context context, Cursor cursor, ViewGroup parent) { View view = super.newView(context, cursor, parent); MessageHolder viewHolder = new MessageHolder(); viewHolder.img_icon = (ImageView)view.findViewById(R.id.sms_headImage); viewHolder.nameTextView = (TextView)view.findViewById(R.id.name); viewHolder.unreadCount = (TextView)view.findViewById(R.id.unread_count); viewHolder.draft = (TextView)view.findViewById(R.id.draft); viewHolder.countTextView = (TextView)view.findViewById(R.id.all_count); viewHolder.date = (TextView)view.findViewById(R.id.date); viewHolder.message = (TextView)view.findViewById(R.id.sms_content); viewHolder.newSms = (ImageView)view.findViewById(R.id.newSms); view.setTag(viewHolder); return view; } @Override public void changeCursor(Cursor cursor) { super.changeCursor(cursor); }}
可以自动的刷新界面,也可以手动刷新界面。当接收到短信时发送一个handler到短信显示界面 进行刷新。
- 查询短信
- 短信查询
- Android查询短信数据库
- Android查询短信数据库
- Android查询短信数据库
- android短信查询
- Android查询短信数据库
- 毕业设计_Android短信查询及加密系统_短信查询
- 中国短信网查询短信状态和余额
- android 短信查询、头像、联系人名称(支持会话和短信)
- 查询与退订中国移动短信服务
- 查询手机通话清单短信内容
- 手机通话短信可以查询码?
- 、查询所有短信,按发件人进行分组
- 电信卡_短信查询指令
- android分页查询垃圾短信数据库信息
- 查询系统sms表短信的数量
- Android ContentProvider 查询备份插入短信
- 优秀开发者必备的四种品质
- 去掉ckeditor+ckfinder去掉服务器浏览那一行
- word 设置单选框|复选框等 (英文版)
- Moss 之五母版页 布局页 Features[转贴]
- C#异常处理
- 短信查询
- Android TimePicker example
- java字符串应用之IP地址转换成整数
- 近期的两个研究
- c#实现控件(ocx)中的事件
- QuickFlow工作流Executing事件中保存值
- LINUX动态库和静态库
- The import java.util cannot be resolved
- c++中new和delete的使用方法