title: Showing null pointer exception in setting the value in model class
body: <p>Here goes my Activity class where there is a log which indicates that there is some value in selectedcategory String. But showing me exception when i am setting the value in my model class</p>
  
  <h1>Activity Class</h1>
  
  <pre><code>private ListView list;
      private MenuItem myActionMenuItem;
      private EditText myActionEditText;
      private TextView myActionTextView;
      private Spinner spinner;
      public Button live_event,save;
      private CategoryModel catModel;
      private String selectedCategory="";
  
  
      //private ArrayList &lt;CategoryModel&gt;categoryList;    
  
      //private static final String[]paths = {"All", "Favourites"};
  
  
      Map&lt;Integer,Integer&gt; categoryList;
      private ArrayList&lt;String&gt; categoryListPosition;
      private String selectCategoryID;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
  
          super.onCreate(savedInstanceState);
  
          setContentView(com.bioscope.R.layout.categorylist);
          save=(Button)findViewById(R.id.save);
  
          categoryList=new HashMap&lt;Integer, Integer&gt;();
  
          RecieveCategoriesTask task = new RecieveCategoriesTask(this,"all");
          task.execute();
  
  
          save.setVisibility(View.VISIBLE);
  
           save.setOnClickListener(new View.OnClickListener() {
  
              @Override
              public void onClick(View v) {
                  // TODO Auto-generated method stub
  
                  for(int i=0;i&lt;categoryList.size();i++)
                  {
                  //Log.i("array", categoryList.get(i).toString());
                  if(categoryList.get(i)==1)
                  {
                      selectedCategory+=categoryListPosition.get(i)+",";
                  }
  
                  }
  
                  Log.i("array", selectedCategory);
                  catModel.setSelectedCategory(selectedCategory);
  
  
                  SendSelectedCategoryTask sendTask = new SendSelectedCategoryTask(
                          CategorySelectonActivity.this,catModel );
                  sendTask.execute();
              }
          } );
  
  
  
      }
  
      public void showcateogryDataLoaded(ArrayList&lt;CategoryModel&gt; categoryList) {
  
              //this.categoryList = categoryList;
  
  
          this.categoryListPosition=new ArrayList&lt;String&gt;();
  
              int count=0;
              for(CategoryModel c:categoryList)
              {
                  Log.v("title", c.getTitle());   
  
                  this.categoryListPosition.add(c.getId());
                  CategorySelectonActivity.this.categoryList.put(count, 0);
                  count++;
              }
  
  
              CategorysListAdapter adapter=new CategorysListAdapter(this, categoryList);
  
              list=(ListView) findViewById(com.bioscope.R.id.listView1);
              list.setAdapter(adapter);
  
              list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
  
                  @Override
                  public void onItemClick(AdapterView&lt;?&gt; parent, View view,
                          int position, long id) {
                      // TODO Auto-generated method stub
                      //Toast.makeText(CategorySelectonActivity.this, "You Clicked an item ", Toast.LENGTH_SHORT).show();
                      //System.out.print("done");
                        //showEventInformaion(position);  
  
  
  
                      CheckBox cb = (CheckBox) view.findViewById(R.id.select_checkbox);
                              if(cb.isChecked())
                              {
                               cb.setChecked(false);
                               CategorySelectonActivity.this.categoryList.put(position, 0);
                               for(int i=0;i&lt;=CategorySelectonActivity.this.categoryList.size();i++)
                                  {
                                      if(i==position)
                                      {
                                          CategorySelectonActivity.this.categoryList.put(i, 0);
                                      }
  
                                  }
  
                              }
                               else 
                              {
                                  cb.setChecked(true);
                                  for(int i=0;i&lt;=CategorySelectonActivity.this.categoryList.size();i++)
                                  {
                                      if(i==position)
                                      {
                                          CategorySelectonActivity.this.categoryList.put(i, 1);
                                      }
  
                                  }
  
                              }
                  }
              });
  
  
      }
  
  
  
      public void visibleSaveButton()
      {
  
          save.setVisibility(View.VISIBLE);
  
      }
  
  
      public void selectedCategoryDataLoaded(String responseString) {
          Utility.showMessage(this, responseString + "");
  
      }
  </code></pre>
  
  <h1>Model Class</h1>
  
  <pre><code>public class CategoryModel {
  
      private String id;
      private String title;
      private String description;
      private String selectedCategory;
      private byte[] icon;
      private boolean status;
  
  
      public byte[] getIcon() {
          return icon;
      }
      public void setIcon(byte[] icon) {
          this.icon = icon;
      }
      public String getId() {
          return id;
      }
      public void setId(String id) {
          this.id = id;
      }
      public boolean getStatus() {
          return status;
      }
  
      public void setStatus(boolean status) {
          this.status = status;
      }
  
      public String getTitle() {
          return title;
      }
      public void setTitle(String title) {
          this.title = title;
      }
      public String getDescription() {
          return description;
      }
      public void setDescription(String description) {
          this.description = description;
      }
  
      public String getSelectedCategory() {
          return selectedCategory;
      }
      public void setSelectedCategory(String s) {
          this.selectedCategory = s;
      }
  </code></pre>
  
  <p>Then Later i get the value in my sendselectedcategorytask class</p>
  
  <h1>SendSelectedCategoryTask Class</h1>
  
  <pre><code>    ProgressDialog dialog;
      String responseString;
      String url;
      //String pageUrl = "createevent";
      CategorySelectonActivity appContext;
      private String userIdParameter="user_id=";
      CategoryModel catModel;
  
      public SendSelectedCategoryTask(CategorySelectonActivity c, CategoryModel model) {
          appContext = c;
          catModel = model;
  
          // url = Utility.baseUrl + pageUrl;
          url = " http://bioscopebd.com/mobileappand/userincategory?"+userIdParameter+"601514140076364784";
  
      }
  
  
      protected void onPreExecute() {
  
          dialog = new ProgressDialog(appContext);
          dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
          dialog.setMessage("Saving Categories...");
          dialog.show();
          super.onPreExecute();
  
      }
  
      String filterResponseString(String r) {
          return r.replace("\r\n", "");
      }
  
  
  
      @Override
      protected String doInBackground(String... params) {
          // TODO Auto-generated method stub
  
          HttpClient httpclient = new DefaultHttpClient();
          HttpResponse response;
          HttpPost httppost;
  
          try {
  
              httppost = new HttpPost(url);
  
              @SuppressWarnings("deprecation")
              MultipartEntityBuilder entity = MultipartEntityBuilder.create();
  
  
  
  
              entity.addPart("event_cat_id", new StringBody(catModel.getSelectedCategory()));
  
  
              httppost.setEntity(entity.build());
  
  //          Log.v("Event Info",
  //                  "Title: " + eventModel.getTitle() + "Description: "
  //                          + eventModel.getDescription() + "Category: "
  //                          + eventModel.getCategoryId() + "Publish Date: "
  //                          + eventModel.getPublishDate() + "Start Date: "
  //                          + eventModel.getStartDate() + "End Date: "
  //                          + eventModel.getEndDate() + "Start Time: "
  //                          + eventModel.getStartTime() + "End Time: "
  //                          + eventModel.getEndTime() + "Logo: "
  //                          + eventModel.getLogo() == null ? "NULL"
  //                          : eventModel.getLogo().toString() + "Banner: "
  //                                  + eventModel.getBanner() == null ? "NULL"
  //                                  : eventModel.getBanner().toString());
  
              response = httpclient.execute(httppost);
              StatusLine statusLine = response.getStatusLine();
  
              if (statusLine.getStatusCode() == HttpStatus.SC_OK) {
  
                  ByteArrayOutputStream out = new ByteArrayOutputStream();
                  response.getEntity().writeTo(out);
                  out.close();
                  responseString = out.toString();
                  responseString = filterResponseString(responseString);
  
                  Log.v("RESPONSE ", "Response: " + responseString);
              } else {
                  // Closes the connection.
                  response.getEntity().getContent().close();
  
                  Utility.showMessage(appContext, "Cannot Connect To Internet");
              }
  
          } catch (Exception e) {
              Log.e("Err", e.getMessage());
              // TODO Handle problems..
          }
          return responseString;
  
  
      }
  
  
      @Override
      protected void onPostExecute(String result) {
  
          dialog.dismiss();
  
          if (responseString != null) {
  
  
              appContext.selectedCategoryDataLoaded(responseString);
  
              // appContext.createEventDataLoaded();
  
          }
  
          super.onPostExecute(result);
  </code></pre>
  
  <p>// Do anything with response..
      }</p>
  
  <h1>Logcat</h1>
  
  <pre><code>11-15 11:19:00.589: E/AndroidRuntime(1099): FATAL EXCEPTION: main
  11-15 11:19:00.589: E/AndroidRuntime(1099): Process: com.bioscope, PID: 1099
  11-15 11:19:00.589: E/AndroidRuntime(1099): java.lang.NullPointerException
  11-15 11:19:00.589: E/AndroidRuntime(1099):     at com.bioscope.main.CategorySelectonActivity$1.onClick(CategorySelectonActivity.java:89)
  11-15 11:19:00.589: E/AndroidRuntime(1099):     at android.view.View.performClick(View.java:4438)
  11-15 11:19:00.589: E/AndroidRuntime(1099):     at android.view.View$PerformClick.run(View.java:18422)
  11-15 11:19:00.589: E/AndroidRuntime(1099):     at android.os.Handler.handleCallback(Handler.java:733)
  11-15 11:19:00.589: E/AndroidRuntime(1099):     at android.os.Handler.dispatchMessage(Handler.java:95)
  11-15 11:19:00.589: E/AndroidRuntime(1099):     at android.os.Looper.loop(Looper.java:136)
  11-15 11:19:00.589: E/AndroidRuntime(1099):     at android.app.ActivityThread.main(ActivityThread.java:5017)
  11-15 11:19:00.589: E/AndroidRuntime(1099):     at java.lang.reflect.Method.invokeNative(Native Method)
  11-15 11:19:00.589: E/AndroidRuntime(1099):     at java.lang.reflect.Method.invoke(Method.java:515)
  11-15 11:19:00.589: E/AndroidRuntime(1099):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
  11-15 11:19:00.589: E/AndroidRuntime(1099):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
  11-15 11:19:00.589: E/AndroidRuntime(1099):     at dalvik.system.NativeStart.main(Native Method)
  </code></pre>