title: NumberFormatException in Android
body: <p>I'm making an application in which the user can add Store departments and for those departments the ability to add the cities of where the departments are located. </p>
  
  <p>I keep on getting a NumberFormatException when I'm trying to add a city for a departement:</p>
  
  <pre><code>Caused by: java.lang.NumberFormatException: Invalid long: "null"
              at java.lang.Long.invalidLong(Long.java:124)
              at java.lang.Long.parseLong(Long.java:345)
              at java.lang.Long.parseLong(Long.java:321)
              at org.hello.addgroups.vestiging_list.onCreate(vestiging_list.java:45)
  </code></pre>
  
  <p>after this the app crashes but when I restart the app the values are added into the list.</p>
  
  <p>these are my classes:
  Add_vestiging.java:</p>
  
  <pre><code>public class Add_vestiging extends Activity implements View.OnClickListener{
  
  EditText et,hiddenet;
  Button add_bt, cancel_btn;
  SQLController dbcon;
  Intent i;
  Long groupd;
  
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.add_new_vestiging);
      et = (EditText)findViewById(R.id.vestigingName);
      add_bt = (Button) findViewById(R.id.addBtn);
      cancel_btn = (Button) findViewById(R.id.cancelBtn);
  
      dbcon = new SQLController(this);
      try {
          dbcon.open();
      } catch(SQLException e) {
          e.printStackTrace();
      }
      i = getIntent();
      String id = i.getStringExtra("groupID");
      groupd = Long.parseLong(id);
      add_bt.setOnClickListener(this);
      cancel_btn.setOnClickListener(this);
  }
  
  @Override
  public void onClick(View v) {
          switch(v.getId()) {
              case R.id.addBtn:
                  String name = et.getText().toString();
                  try {
                      dbcon.insertVestiging(groupd, name);
                  }catch(SQLiteException e) {
                      e.printStackTrace();
                  }
                  Intent main = new Intent(Add_vestiging.this, vestiging_list.class);
                  startActivity(main);
                  break;
              case R.id.cancelBtn:
                  super.finish();
                  break;
  
          }
  }
  }
  </code></pre>
  
  <p>vestiging_list.java: </p>
  
  <pre><code>public class vestiging_list extends Activity {
  
          ListView lv;
          SQLController dbcon;
          TextView title;
          Button addves;
          Long long_id;
          String groupid;
          Intent add_ves;
          String groupname;
          protected void onCreate(Bundle savedInstanceState) {
                  super.onCreate(savedInstanceState);
                  setContentView(R.layout.vestiging_list);
                  dbcon = new SQLController(this);
                  title = (TextView) findViewById(R.id.vestitel);
  
  
                  try {
                          dbcon.open();
                  } catch (SQLException e) {
                          e.printStackTrace();
                  }
                  add_ves = getIntent();
                  groupid = add_ves.getStringExtra("groupID");
                  groupname = add_ves.getStringExtra("groupName");
                  title.setText(groupname);
                  long_id = Long.parseLong(groupid);
  
                  addves = (Button)findViewById(R.id.addves_bt_id);
                  lv = (ListView)findViewById(R.id.vestigingList_id);
  
                  addves.setOnClickListener(new View.OnClickListener() {
                          @Override
                          public void onClick(View v) {
  
                                  add_ves = new Intent(getApplicationContext(), Add_vestiging.class);
                                  add_ves.putExtra("groupID", groupid);
                                  startActivity(add_ves);
                          }
                  });
  
                  Cursor cursor = dbcon.readVestigingen(long_id);
                  String[] from = new String[] { GroupDatabaseHelper.V_ID, GroupDatabaseHelper.VESNAME};
                  int[] to = new int [] { R.id.vesID, R.id.vesName};
  
                  SimpleCursorAdapter adapter = new SimpleCursorAdapter(vestiging_list.this, R.layout.vestiging_single_row_item, cursor, from, to,1);
                  adapter.notifyDataSetChanged();
                  lv.setAdapter(adapter);
  
                       }
  }
  </code></pre>
  
  <p>Any ideas on how to remove the NumberFormatException?
  Any help is greatly appreciated.</p>
  
  <p>Thanks in advance. </p>