title: Sending Long to Shared Preferences - Android
body: <p>I've developed a dialog box that prompts a user to enter his/her phone number when the app first runs but I'm having trouble adding it to the shared preferences. I have the SP set up and working correctly from another view (to add/edit info) and I was able to commit a user id. The problem is that I'm using a Long for the phone number instead of a string, so I keep getting errors and can't seem to figure out what I need to do. I think the Editable may also be an issue. I've tried changing getText() to getLong() but that doesn't seem to work and I can't convert it to a string because the phone number is recognized as a Long in my SP. How can I commit the Long to the shared preferences? Thanks.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>    if(phone == 0) {
          AlertDialog.Builder alert = new AlertDialog.Builder(this);
  
          alert.setTitle("Please Enter Your Phone Number");
          alert.setMessage("You must enter your phone number in order to use this application");
  
          final EditText input = new EditText(this);
          alert.setView(input);
  
          alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int whichButton) {
          Editable value = input.getText();
  
          Editor editor = shared.edit();
          editor.putLong("PHONE", value); //wants me to change putLong to putString
          editor.commit();
           }
          });
          alert.show();     
      }
  </code></pre>