I'm trying to develop a small app which receives some data via sockets and based on the data it receives,it prints a toast message for the user.I' getting the data,but the data apparently cannot be read properly.Here is the relavent portion for the same.
 int red = -1;
 byte[] buffer = new byte[1024]; // a read buffer of 5KiB
 byte[] redData;
 while ((red = cs.getInputStream().read(buffer)) > -1) {
     String redDataTextappend;
     redData = new byte[red];
     redDataTextappend = new String(redData);
     Log.w("Data got",redDataTextappend);
     if (redDataTextappend == "hi") 
       {
         //Display Toast message using runonUIThread(new Runnable);
       }
     else 
         {//Display Message Using runonUITHread(new Runnable);
         }
This code runs on a separate thread as android does not allow networking operations on a separate thread.
The 4 Diamonds is the data displayed by the android studio and cs is the name of the socket which accepts connections.
Thanks.

 
    