Example code, illustrating the usage of the Secure App ROM
- 26 Dec 2024
- 1 Minute à lire
- SombreLumière
- PDF
Example code, illustrating the usage of the Secure App ROM
- Mis à jour le 26 Dec 2024
- 1 Minute à lire
- SombreLumière
- PDF
The content is currently unavailable in French. You are viewing the default English version.
Résumé de l’article
Avez-vous trouvé ce résumé utile ?
Merci pour vos commentaires
The example shows a class SARExample which provides some API to load data from the Secure App ROM for a single fixed key.
Function retrieving data from the Secure App ROM.
package com.example.sar; import java.io.IOException; import java.io.InputStream; import java.io.BufferedReader; import java.io.InputStreamReader; import android.content.Context; import no.promon.shield.storage.rom.SecureAppRom; public class SARExample { private static final String KEY = "secret/Text"; String getSecretText(Context context) throws IOException { InputStream is = SecureAppRom.getInstance(context).open(KEY); // Read the stream StringBuilder text = new StringBuilder(); BufferedReader reader = new BufferedReader(new InputStreamReader(is)); String line; while ((line = reader.readLine()) != null) { text.append(line); } return text.toString(); } }
The function calls SecureAppRom.getInstance() to get a SecureAppRom instance and then opens an InputStream for the file assets/sarom/secret/Text by calling SecureAppRom.open("secret/Text") and finally reads the content from the input stream as a text file.
Cet article vous a-t-il été utile ?