我有一个小查询。如何获取仅存储在内部数据库中的特定移动号码的SMS。这是我尝试的下面的代码,但我只能得到一个数字
for (Contact_pojo contpojo: smslist) {
while (cur.moveToNext()) {
SMS_Adapter sms_adapter = new SMS_Adapter();
if (cur.getString(cur.getColumnIndexOrThrow("address")).equals("+91"+contpojo.getContactnumber())){
sms_adapter.setSmsname(cur.getString(cur.getColumnIndexOrThrow("address")));
sms_adapter.setSmsaddress(cur.getString(cur.getColumnIndexOrThrow("body")));
smsadapter.add(sms_adapter);
}
}
}
答案 0 :(得分:0)
试试这个
SMS_Adapter sms_adapter = new SMS_Adapter();
for (Contact_pojo contpojo: smslist) {
while (cur.moveToNext()) {
if (cur.getString(cur.getColumnIndexOrThrow("address")).contains("+91"+contpojo.getContactnumber())){
sms_adapter.setSmsname(cur.getString(cur.getColumnIndexOrThrow("address")));
sms_adapter.setSmsaddress(cur.getString(cur.getColumnIndexOrThrow("body")));
smsadapter.add(sms_adapter);
}
}
}
您可以使用contains
方法代替equals