Android: String to Long Results in Null Value
<p>I'm trying to get a "<strong>long</strong>" value from a String containing a Facebook ID, which is a <strong>10 digit number</strong>. Here's what my function looks like:</p>

<pre><code>@Override
    public void onItemClick(AdapterView&lt;?&gt; arg0, View v, int position, long arg3) {
        try {
            final long opponentId;            
            opponentId = jsonArray.getJSONObject(position).getLong("uid");
            String opponentName = jsonArray.getJSONObject(position).getString("name");
            Toast.makeText(this, "UID: " + opponentId + "\n" + "Name: " + opponentName, Toast.LENGTH_SHORT).show();

            SharedPreferences myPrefs = getSharedPreferences("user", MODE_WORLD_READABLE);
            String playerUidString = myPrefs.getString("uid", null);


            if (playerUidString == null) {
                Log.d(GlobalVars.TAG, "Empty UID");
                return;
            }

            Log.d(GlobalVars.TAG, "ID: " + playerUidString);
            Log.d(GlobalVars.TAG, "ID Long: " + String.valueOf(Long.getLong(playerUidString)));

//           long player_id = Long.getLong(playerUidString);
//          new GameRequest(getBaseContext(), player_id, opponentId);


        } catch (JSONException e) {
            Log.d(GlobalVars.TAG, e.getMessage());
        }
    }
</code></pre>

<p>Normally, I would set long player_id to equal the conversion of playerUidString to long, but Long.getLong(playerUidString) results in null, while playUidString equals the 10 digit ID number. Any reason why this is happening?</p>

<p>Edit: My Log.d outputs:</p>

<pre><code>06-29 11:06:37.823: D/I See It(16053): ID: 1089490706
06-29 11:06:37.823: D/I See It(16053): ID Long: null
</code></pre>
