public class MATUtils extends Object
Constructor and Description |
---|
MATUtils() |
Modifier and Type | Method and Description |
---|---|
static String |
bytesToHex(byte[] data) |
static boolean |
getBooleanFromSharedPreferences(Context context,
String prefsKey)
Retrieves a boolean from SharedPreferences
|
static String |
getStringFromSharedPreferences(Context context,
String prefsKey)
Retrieves a String from SharedPreferences
|
static byte[] |
hexToBytes(String str) |
static String |
md5(String s) |
static String |
readStream(InputStream stream)
Reads an InputStream and converts it to a String
|
static void |
saveToSharedPreferences(Context context,
String prefsKey,
boolean prefsValue)
Saves a boolean to SharedPreferences
|
static void |
saveToSharedPreferences(Context context,
String prefsKey,
String prefsValue)
Saves a String to SharedPreferences
|
static String |
sha1(String s) |
static String |
sha256(String s) |
public static void saveToSharedPreferences(Context context, String prefsKey, String prefsValue)
context
- Context to access SharedPreferences ofprefsKey
- SharedPreferences key to save underprefsValue
- SharedPreferences value to savepublic static void saveToSharedPreferences(Context context, String prefsKey, boolean prefsValue)
context
- Context to access SharedPreferences ofprefsKey
- SharedPreferences key to save underprefsValue
- SharedPreferences value to savepublic static String getStringFromSharedPreferences(Context context, String prefsKey)
context
- Context to access SharedPreferences ofprefsKey
- SharedPreferences key of the value requestedpublic static boolean getBooleanFromSharedPreferences(Context context, String prefsKey)
context
- Context to access SharedPreferences ofprefsKey
- SharedPreferences key of the value requestedpublic static String readStream(InputStream stream) throws IOException, UnsupportedEncodingException
stream
- InputStream to readIOException
- Reader was closed when trying to be readUnsupportedEncodingException
- UTF-8 encoding could not be foundpublic static String bytesToHex(byte[] data)
data
- Byte array to convert to hexpublic static byte[] hexToBytes(String str)
str
- Hex string to convert to bytespublic static String sha1(String s)
s
- String to SHA-1 hash