title: How to save scroll bar values using sharedPreferences in android
body: <p>How could I change the value of a variable using sharedPreferences to update a string and pass it to Arduino using Socket.
  I am using inputStremBuffer and outputWriter, I just want to update the value of a variable and pass it to server to perform operations (e.g. Light On/Off and intensity control)</p>
  
  <p><a href="https://i.stack.imgur.com/YSG7s.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YSG7s.png" alt="enter image description here"></a></p>
  
  <pre><code>&lt;ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:fillViewport="true"&gt;
  
      &lt;RelativeLayout
          android:id="@+id/data_entry_layout"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:layout_centerHorizontal="true"
          android:paddingBottom="@dimen/activity_vertical_margin"
          android:paddingLeft="@dimen/activity_horizontal_margin"
          android:paddingRight="@dimen/activity_horizontal_margin"
          android:paddingTop="@dimen/activity_vertical_margin"&gt;
      &lt;RelativeLayout
          android:id="@+id/Rel12345"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"&gt;
  
          &lt;TextView
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:id="@+id/temerature_show"
              android:layout_marginEnd="30dp"
              android:layout_marginStart="20dp"
              android:text="Rome Temerature"
              android:textSize="35dp"
              /&gt;
          &lt;TextView
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_below="@+id/temerature_show"
              android:layout_marginTop="10dp"
              android:layout_marginEnd="100dp"
              android:layout_marginStart="100dp"
              android:hint="temp value"
              android:id="@+id/temerature_value"
              /&gt;
          &lt;TextView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="Light 1"
              android:layout_below="@+id/temerature_value"
              android:layout_marginStart="20dp"
              android:textSize="20dp"
              android:layout_marginTop="50dp"
              android:id="@+id/light1"
              /&gt;
          &lt;ToggleButton
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              style="@style/toggleButton"
              android:scrollbarSize="@android:dimen/app_icon_size"
              android:background="@drawable/light_button_bg"
              android:layout_below="@+id/temerature_value"
              android:layout_alignParentRight="true"
  
              /&gt;
          &lt;SeekBar
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:id="@+id/seekbarlight1"
              android:layout_below="@+id/light1"
              android:layout_marginTop="20dp"
              /&gt;
          &lt;Button
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:id="@+id/buttonlight1"
              android:layout_below="@+id/seekbarlight1"
              android:layout_alignParentRight="true"
              android:text="Send"
              /&gt;
          &lt;TextView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="Light 2"
              android:layout_below="@+id/buttonlight1"
              android:layout_marginStart="20dp"
              android:textSize="20dp"
              android:layout_marginTop="50dp"
              android:id="@+id/light2"
  
              /&gt;
          &lt;ToggleButton
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              style="@style/toggleButton"
              android:scrollbarSize="@android:dimen/app_icon_size"
              android:background="@drawable/light_button_bg"
              android:layout_below="@+id/buttonlight1"
              android:layout_alignParentRight="true"/&gt;
          &lt;SeekBar
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:id="@+id/seekbarlight2"
              android:layout_below="@+id/light2"
              android:layout_marginTop="20dp"
  
              /&gt;
          &lt;Button
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:id="@+id/buttonlight2"
              android:layout_below="@+id/seekbarlight2"
              android:layout_alignParentRight="true"
              android:text="Send"
              /&gt;
  
          &lt;TextView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="Fan"
              android:layout_below="@+id/buttonlight2"
              android:layout_marginStart="20dp"
              android:textSize="20dp"
              android:layout_marginTop="50dp"
              android:id="@+id/fan"
  
              /&gt;
          &lt;ToggleButton
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              style="@style/toggleButton"
              android:scrollbarSize="@android:dimen/app_icon_size"
              android:background="@drawable/fan_button_bg"
              android:layout_below="@+id/buttonlight2"
              android:layout_alignParentRight="true"/&gt;
  
  
          &lt;SeekBar
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:id="@+id/seekbarlight3"
              android:layout_below="@+id/fan"
              android:layout_marginTop="20dp"/&gt;
          &lt;Button
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:id="@+id/buttonlight3"
              android:layout_below="@+id/seekbarlight3"
              android:layout_alignParentRight="true"
              android:text="Send"
              /&gt;
          &lt;ToggleButton
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              style="@style/toggleButton"
              android:scrollbarSize="@android:dimen/app_icon_size"
              android:background="@drawable/motion_button_bg"
              android:layout_below="@+id/buttonlight3"
              android:layout_alignParentRight="true"/&gt;
          &lt;TextView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="Motion Sensor"
              android:layout_below="@+id/buttonlight3"
              android:layout_marginStart="20dp"
              android:textSize="20dp"
              android:layout_marginTop="50dp"
              android:id="@+id/motion"/&gt;
          &lt;ToggleButton
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              style="@style/toggleButton"
              android:scrollbarSize="@android:dimen/app_icon_size"
              android:background="@drawable/temerature_button_bg"
              android:layout_below="@+id/motion"
              android:layout_alignParentRight="true"/&gt;
          &lt;TextView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="Temerature Sensor"
              android:layout_below="@+id/motion"
              android:layout_marginStart="20dp"
              android:textSize="20dp"
              android:layout_marginTop="50dp"
              android:id="@+id/temeraturetext"/&gt;
  
      &lt;/RelativeLayout&gt;
      &lt;/RelativeLayout&gt;
  &lt;/ScrollView&gt;
  </code></pre>