0

In terms of context for what I'm doing, I have an ArrayList with some String[]-typed contacts in it (has a {name, phone number, phone type} per entry) for the native android address book feature. I want to store this list of contacts, and then bring them back up whenever a new list of contacts is added so that I can compare the two for differences. However, I'm not entirely sure what I could do to store one for later use. I was going to use SharedPreferences, but at the most it only takes a Set, not an ArrayList; plus, since it's contacts, a Set may prove to be problematic in the event of any duplicate values.

The other option I considered was some sort of conversion into another type that SharedPreferences accepts, then converting it back after retrieving it. I had to put a pin in that as well because a lot of those methods require external libraries that I cannot add to this project (for dependencies).

Are there any native methods I could use in order to properly store an ArrayList<String[]> for later comparisons?

mbob98
  • 61
  • 6
  • 2
    Is there a reason why you use a String array instead of a "Contact" model class? – Tom May 16 '22 at 19:56
  • @Tom not entirely sure of the reasoning... I'm just doing some maintenence and trying to optimize the app as-is. Logically, a cursor is used to query a ContentResolver with a given URI, and each value pulled via the cursor is then used to populate an entry in the entries array list. Beyond that, I don't know the rhyme or reason as to why this strategy was used. – mbob98 May 16 '22 at 20:01

1 Answers1

0

The proper way would be to use a contact class combined with sqlite table.

However, you could also create an xml/text file to store your arraylist data and read it back when needed.