because you used "==" ... this isnt C#... in Java that will not return true.
please look up some info on string comparison and the definition of "==" vs
equals()
On Monday, December 10, 2012 3:38:05 AM UTC-5, Antonis Kanaris wrote:
>
>
> Hello.I have a simple file.txt with only data the 1 but when put
> if(value=="1") no work why?
>
> File sdcard = Environment.getExternalStorageDirectory();
>
> //Get the text file
> File file = new File(sdcard,"LEDstate.txt");
>
> byte[] byteArray = new byte[(int) file.length()];
> try {
> new FileInputStream(file).read(byteArray);
> } catch (Exception e) {
> e.printStackTrace();
> }
>
> String value = new String(byteArray);
>
> if(value=="1"){
> //Find the view by its id
> TextView tv = (TextView)findViewById(R.id.txt);
>
> //Set the text
> tv.setText(value);
> // }
>
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en