Q:

Where to store IV that is needed for decryption in Android app?

Where should I store the IV (byte array) needed for AES decryption in my Android app? I've tried converting it to a string in Base64 and saving it to shared preferences, but kept getting a bad padding exception. I tried to change the padding, but it didn't work.
I also saved the IV (byte array) to the keystore's provider and that worked, but while debugging in Visual Studio for Mac, the provider's content (in this case the IV) gets erased every time I run the app. The provider is still there but nothing is saved in the provider. Android's documentation says that "Each provider... is configured in each runtime it is installed in." Will this be an issue once the app is installed on an actual device?
I am coding in c# in Visual Studio for Mac.
Edit
this is my code using Base64 encoding:
string ivString = Base64.EncodeToString(ivByteArray, Base64Flags.Default);
byte[] decodedIV = Base64.Decode(ivString, Base64Flags.Default);
when I print out the original byte array and the decoded byte array, they are exactly the same but I keep getting a bad padding exception
I am using AES, CBC, and EncryptionPaddingPkcs7

A:

I've tried converting it to a string in Base64 and saving it to shared preferences, but kept getting a bad padding exception.

Storing IV in SharedPreferences should work. You probably got a base64 encoding issue.

I also saved the IV (byte array) to the keystore's provider and that worked, but while debugging in Visual Studio for Mac, the provider's content (in this case the IV) gets erased every time I run the app.

A java.security.Provider it is not the place to store a bytearray. Do you mean Android Keystore System or other implementation of java.security.KeyStore. Please be specific

Where to store IV that is needed for decryption in Android app?

Just prepend the initialiation vector to the ciphertext
 [IV][ciphertext]

