title: Android SQL cursor is NULL
body: <p>In my sql.query, there are times when the cursoe should return a null value.  For example in the below code, the cursor is seeking a username. If the User has a username, then the cursor will return it.  If not then I assume it is null.  My problem is that when a cursor does find a null value, then I get a crash with an "out of bounds" error.  Basically means the cursor did not find anything.</p>
  
  <pre><code>   public static String getUserName() {
  
          int rowIncrement = 1; 
          Log.d(DATABASE, "Getting Username");
          String[] usercolumns = new String[] { KEY_ROWID, KEY_NAME, KEY_PASSWORD };
          Cursor c = myDatabase.query(USER_TABLE, usercolumns, KEY_ROWID + "="
                  + rowIncrement, null, null, null, null);
          if (c != null) {
              c.moveToFirst();
              String lUserName = c.getString(1);
              Log.d("DATABASE", "Username = " + lUserName);
              return lUserName;
          }
          return null;
      }
  </code></pre>
  
  <p>What is wrong with this code that would cause a crash if the cursor does not find anything?</p>