Here is the Python code. For the full, unnecessary story, keep reading.
For years I was a loyal user of Textra. It had dark mode long before stock Android messaging apps did, and its other customization options were a welcome bonus. A critical bug recently soured me on the app, though — I discovered that my texts were not transferring to a new phone because Textra had not been syncing with the stock message database.
A brief explanation: while you can use many different apps to organize and compose texts, the Android OS itself has to handle sending and receiving them. Therefore, texts are usually stored in a system database that is made accessible to third-party apps. These apps can (and often do) manage texts internally in application-specific partitions inaccessible to other apps1, but sync with the system database for consistency. This is how Textra works — it has its own database and copies messages into the system database for consistency.
At least that’s how it’s supposed to work. Sometimes it does not copy messages over, and that is bad. How do we fix this?
We could force a resync with the system database. Textra can do this but sometimes, without warning, it destructively wipes out all texts instead. Not good!
A safer option is to export our messages in a nice and tidy format like JSON or CSV or even XML, and load them into the system database by other means. Since the texts are already stored in a logical schema (they are in a database after all), it would be a cinch to export them. This also doubles as a backup and restore mechanism, letting us sleep soundly knowing that no matter what happens to com.textra
we can always load up some backup.csv
and restore our years of text messages.
Surprise! Textra doesn’t do this. Despite it being one of the most highly rated requests on the Textra feedback forum, the developer team claims that there are third-party apps to manage exports and that they “want to focus on core features in Textra.” They don’t mention what these “core features” are but presumably “fixing messaging syncing so people can backup their texts” should be on that list. Many of the upset people commenting on that request would appreciate it.
How did I recover my texts then? “No backups” is not entirely true, actually. There is a half-hearted export feature in Textra, called “Share as email.” For a single contact at a time, you can get a text file:
Conversation with James Calixto ((212) 664-7665)
[1/25/21 11:33 PM] Me: Hello
[1/25/21 11:33 PM] James Calixto: Hello
[1/25/21 11:34 PM] Me: Why doesn't Textra have an export feature?
[1/25/21 11:34 PM] James Calixto: I was wondering that too
...
This is not a great format to read from! Granted, it’s not horrrible — you can parse the name and phone number2 and extract timestamps and the sender of each message and so on — but the important bit is that you can’t click a button and pop the texts back into the database.
So of course I wrote a script to do this. It parses different text backups (each contact is one file, remember) from the “Share as email” function and combines the messages into an XML file that can be restored by a third-party app. Now my messages are neatly squared away. Your mileage may vary, of course.
The real takeaway: if your app’s functionality relies on storing user-created records locally, and it would be a Bad Thing if those records were deleted, let the user make backups! You should be scared for their data!
Maybe you forget fileWriter.close()
in your next update and the app clobbers their records, maybe a cosmic ray bitflips a hash and it grinds your parsing logic into dust, maybe a crow steals the phone because it’s shiny and it’s lost forever. If they can restore from backup.csv
they probably won’t even remember it the next day3. If they can’t… would you trust an app that irrecoverably lost years of your data, knowing that it could happen again?
There’s a good chance you’ll never regain their trust. Once bitten, twice shy – goodbye, Textra.
And yes, Bookish offers backups.
If you root your phone, you can access these. You can also brick your phone in the process. If you’re trying to recover the only copy of your text messages and you brick your phone, you will not be happy. ^
Not my real number, obviously. Call it and you might get someone at Universal Studios though. ^
Well, not if the crow steals it. They’ll remember that one. ^