我不明白我的代码有什么问题。我在 myAddressUniqueness 中遇到错误。不知道为什么。在我尝试使用字符串数据类型但得到相同的错误之前。它说 java.null 异常。
ArrayList<String> myAddressUniqueness = null;
String name = "hello";
if (indexBody < 0 || !cursor.moveToFirst())
return;
smsList.clear();
do {
// int cursorPostion = cursor.getPosition();
String address;
String msgStr = cursor.getString(indexBody);
String senderNumber = cursor.getString(indexAddr);
Log.d("Name : ", senderNumber);
// String name = cursor.getString(cursor
// .getColumnIndex(PhoneLookup.DISPLAY_NAME));
// Log.d("Name : ",name);
if (name != null) {
address = name;
} else {
address = senderNumber;
}
Log.d("Address: ", address);
flag = 1;
//Log.e("Number: ", addressUniqueness.length + "");
for (j = 0; j < myAddressUniqueness.size(); j++) {
if (myAddressUniqueness.contains(address)) {
flag = 0;
break;
}
}
if (flag == 1) {
myAddressUniqueness.add(new String(address));
i++;
String str = "Sender: " + address + "\n";
smsList.add(str);
}
// TODO Auto-generated catch block
} while (cursor.moveToNext());