Adding textmessages together depending on sender from an ArrayList [Android]
<p>Okay, keep in mind that I'm new to Android and I'm simply put not any good at java.</p>

<p>I've got a method that checks through a list of sms's and add's sms messages that starts/ends with specified characters to an arrayList. </p>

<pre><code>public boolean checkForKey(Object[] smsList) {
    //Go through sms list searching for key, add each that starts/ends with correct characters to an arrayList..
    //do something productive

    String str = "";
    for(int i= 0; i &lt; smsList.length; i++){
        SmsMessage sms = SmsMessage.createFromPdu((byte[])smsList[i]);
        String body = sms.getMessageBody().toString();

        if(body.startsWith("-?-") || body.endsWith("-?!-")){
            msgList.add(sms);
        }
    }

    if(msgList == null){
        return false;
    }
    return true;
}
</code></pre>

<p>So basically what I want to do is pair together messages from a specified sender, I'll give an example as I'm not great at getting my point across:</p>

<p>David sends these two messages:</p>

<p>-?-
blajaheiuhfahiufeihuhiuhfuheuaiifahhafhbehb</p>

<p>and</p>

<p>kahefkhafkehauiefhiuahfeiuhaiefuhauiehiafhe
-?!-</p>

<p>so I want to put them together into a single string.</p>

<p>Any thoughts on how to do this? </p>

<p>Okay, so updating my thoughtline,</p>

<pre><code>String address = sms.getOriginatingAddress();

        if(body.startsWith("-?-")) { //|| body.endsWith("-?!-")){
            str = body;
            // msgList.add(sms);
        }
        if(body.endsWith("-?1-")) {
            str += body;
        }
</code></pre>

<p>So say that str is equal to the first half of the message (key in my case), now I want to add the second half by finding the message that ends with -?!- and has the same address (sender)- how can I do this? I mean make sure they have the same sender?</p>
