views:

144

answers:

2

Does anybody know what data structures are used to the store messages in an SMS client app, and whether there is an existing API for this.

I was perhaps looking at implementing a link list for the purpose but if the work has already been done in an API then perhaps it would be unnecessary to commit time to the task that could be spent programming other parts.

Many thanks

+1  A: 

In android there is android.telephony.SmsMessage. This is the object used within android to store a single SMS message. You can look at that and build something that resembles it, or reuse it.

As far as the data structure for storing them, I would suggest you use a java.util.List<E>, which gives you much more flexibility over some of the other data structures, like a standard array[].

If you're looking at storing your SMS messages over a longer period of time, then I would also suggest you take a look at persistence using SQLlite, which is also a part of the Android platform.

Ryan Hayes
+1  A: 

As for the built-in Messaging app, it's storing all the messages in a database. You can check out the Android source code to see what it does, but I would recommending against reading this data - it's not part of the official SDK, so it might change, or some phones might not have it.

As for storing it yourself - I wouldn't use a linked list. Use a database, that's the preferred way to store any persistent data (other than little individual values, for which you use SharedPreferences).

EboMike