The Problem:
I'm currently writing an app for Android API Level 19 (Yeah, I know it's pretty old). I'm running into a problem with serializing settings data. Part of the problem is that some of the data is confidential and must be encrypted before being written to disk. So there is a mix of encrypted and unencrypted data. The data consists of int, Boolean, String, byte[], and other types.
For those who are interested, when the app starts up, the user must enter their PIN. The PIN is ran through a hash algorithm a few times. In the middle of the run, they crypto key is taken and then the hashing loop runs to completion. So the intermediate result is the key, and the final result is the verification. The verification is written to the settings file while the key is used to encrypt or decrypt the confidential data. There are other safeguards in place, but that is how it works in a nutshell.
Most of the implementations that I have found use HashMap and ObjectOutputStream which cannot be used because of the cryptography issue (according to the examples that I have seen thus far). I did come across the Data class in the Android developer documentation, but Android Studio says that it requires API 29 to use.
Research:
I have found quite a few answers in various places such as:
Reliably convert any object to String and then back again
https://developer.android.com/reference/androidx/work/Data
https://beginnersbook.com/2013/12/how-to-serialize-hashmap-in-java/
https://developer.android.com/guide/topics/security/cryptography#java
...and many others, but I can't really use them because of what I am trying to do.