My android application takes sms messages from a BroadcastReceiver and copies the message into a new sms. Then forwards it. Due to technical reasons I must to split the sms and copy only the portions after split[2]:
public string splitAndReturnRest(String inputStr)
{
String[] split = inputStr.split("\\s"); // split where spaces
// now ignore split[0], split[1], split [2], copy rest of the split parts into
String restOfTheSplits=//copy rest of the splits except split[0], split[1], split[2]
return restOfTheSplits;
}
The problem is I can’t just hard code it. I do not know how many parts the message contains. So the number of elements after split[2] is unknown to me and may change every time. Perhaps I need some kind of for loop, or a different split criteria?
After split[2], use the following….
Its even better if you use
StringBuilderto get therestOfTheSplitsand then convert it to String and return it….