title: Displaying Toast notifications from Java class
body: <p>I want to create a separate class within my application to handle error reporting and send specific errors to a database. However, I'm unable to figure out what the <code>Context</code> should be and how this should be properly coded. I assume it should still be possible, I just need to code it differently, if that is not the case, what is the best solution for me?</p>
  
  <pre><code>public class SendError implements Runnable
  {
  
      private String url;
  
      public SendError(String errors, String form, String database, String SQL)
      {
          url = string;
  
          Handler handler = new Handler();        
          handler.post(new Runnable() {
              public void run() {
                  Toast toast = Toast.makeText(getContext, msg, Toast.LENGTH_LONG);
                  toast.show();
              }
          });
      }
  }
  </code></pre>
  
  <p><strong>EDIT:</strong></p>
  
  <p>What I'm trying to do is create one class for my entire application that handles recording of SQL errors when submitting data to the database. The class needs to do 2 simple things. Submit information based on what form, database, time submitted, and the SQL code that created the error. The other thing I would like this class to do is to display a toast giving basic error information back to the user. I have the data submission portion of this worked out properly (hence the reason for the <code>Runnable</code>), but am still getting errors for the Toast.</p>