I use google voice. It keeps a record of every text, call, and voicemail.... forever.
Also, the audio files can be downloaded as .mp3s
The only bad part is it doesn't handle texted photos.
I'd think that in court it would go something like this:
Lawyer: How is the communication with your X.
You: She's is really high conflict and bla bla bla.
Lawyer: Your honor, I'd like to submit into evidence these text messages.
Then, if there are objections, you basically authenticate them yourself. You are under oath and say you remember sending and receiving them and since its just between you and the X, its not hearsay.