I have to convert a byte array to a string. Therefore I use this function:
public static String byteToString(byte[] bytes) {
String str = new String(bytes, Charset.forName("UTF8"));
return str;
}
The problem is, that it requires API 9:
Call requires API level 9 (current min is 8): new java.lang.String
but I want to provide my app to API 8 users too. Is there any possibility or alternative?
You can use new String(bytes, "UTF8") (The constructor String(byte[], String)). It's always available (API level 1+).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With