You can try something like:
String s = "Home";
byte[] b = s.getBytes("US-ASCII");
StringBuffer hexString = new StringBuffer();
for (int i=0;i<b.length;i++) {
hexString.append(Integer.toHexString(0xFF & b[i]));
}
String finalHex = "#" + hexString.substring(0,6);
System.out.println(finalHex);
Generates a hex code: #486f6d
In the same way, create hex for all Stringyou want and add them to HashMapas a key-value pair.
source
share