I am using Kotlin to create and write to an encrypted file stored locally within the app to temporarily store login credentials, On Logout, I want to delete this file.
To create the file I am using the EncryptedFile.Builder method as below;
val encryptedFileName = "UserAuthData_.txt"
val mainKey = MasterKey.Builder(applicationContext)
.setKeyScheme(MasterKey.KeyScheme.AES256_GCM)
.build()
val encryptedFile = EncryptedFile.Builder(
applicationContext,
File(applicationContext.applicationInfo.dataDir, encryptedFileName),
mainKey,
EncryptedFile.FileEncryptionScheme.AES256_GCM_HKDF_4KB
).build()
I want to delete this file but can't find any way of doing so.
Any ideas would be greatly appreciated.
Thank you!
You can simply delete the file using this -
File someFile = new File(encryptedFileName);
someFile.delete();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.