所以即時嘗試刪除電話號碼中的所有特殊字符只留下數字,不幸的是它不工作。我查了其他解決方案,但他們仍然沒有工作。即使在調試器中運行後,似乎.replaceAll()方法根本就沒有做任何事情。這裏是我下面的代碼:String.replaceAll()不工作在我的環島
if (c !=null) {
//populate database with first 100 texts of each contact
dbs.open();
//comparator address, count to 100
String addressX = "";
int count = 0;
c.moveToFirst();
for (int i = 0; i < c.getCount(); i++) {
//get c address
String addressY = c.getString(c.getColumnIndex("address"));
addressY.replaceAll("[^0-9]+", "").trim();
//one for the address, other to be able to sort threads by date !Find better solution!
if (!smsAddressList.contains(addressY)) {
//custom object so listview can be sorted by date desc
String date = c.getString(c.getColumnIndex("date"));
smsDateList.add(date);
smsAddressList.add(addressY);
}
//less than 100 texts, add to database, update comparator, add to count
if (count < 100) {
c.moveToPosition(i);
addText(c);
addressX = addressY;
count++;
}
//if more 100 texts, check to see if new address yet
else if (count>100) {
//if still same address, just add count for the hell of it
if (addressX.equals(addressY)) {
count++;
}
//if new address, add text, reset count
else {
addText(c);
addressX = addressY;
count = 1;
}
}
}
}
我喜歡你loooop的拼法) –
@jan,它可能是由一個迴路中產生一個錯誤的錯誤:-) – paxdiablo