title: best practice for handling exceptions in Background threads in Android apps
body: <p>I've got multiple try/catch blocks in my background thread which initialize and load data/DB. 
  At first I just placed <code>throw new RuntimeException( e );</code> in the catches , but I think I should be handling them instead of just throwing them hoping for someone to handle that.. in which case ,by the way, the app will just crash.</p>
  
  <p>What is the best practice handling these situations(in background threads), particularly in Android apps ?</p>
  
  <p>Thanks.</p>
  
  <p>EDIT :</p>
  
  <pre><code>private static class DatabaseLoaderHelper extends SQLiteOpenHelper 
  {
      private static final int DB_VERSION = 1;
      private static String DB_PATH = "" ;
  
      private DatabaseLoaderHelper( WeakReference&lt;Context&gt; contextWrapper )
      {
          super( contextWrapper.get(), DB_NAME , null, DB_VERSION );
          DB_PATH = contextWrapper.get().getDatabasePath( DB_NAME ).getAbsolutePath();
  
          boolean dataBaseExist = checkDatabaseExist( contextWrapper );
          if ( !dataBaseExist )
          {
              try
              {
                  copyDatabase( contextWrapper.get() );
              }
              catch ( IOException e )
              {
                  throw new RuntimeException( e );
  
              }
          }
      }
  
      private void copyDatabase( Context context ) throws IOException
      {
          InputStream myInput = null;
          String outFileName = null;
          OutputStream myOutput = null;
  
          try
          {
              myInput = context.getAssets().open( DB_NAME );
  
              outFileName = DB_PATH;
  
              myOutput = new FileOutputStream( outFileName );
  
              byte[] buffer = new byte[ 1024 ];
              int length;
  
              while ( ( length = myInput.read( buffer ) ) &gt; 0 )
              {
                  myOutput.write( buffer, 0, length );
              }
          }      
          catch( IOException e )
          {
  
          }
          finally
          {
              myOutput.flush();
              myOutput.close();
              myInput.close();
          }
      }
  
      private boolean checkDatabaseExist( WeakReference&lt;Context&gt; contextWrapper )
      {
  
          File dbFile = new File( DB_PATH + DB_NAME );
          if ( !dbFile.getParentFile().exists() )
          {
              dbFile.getParentFile().mkdir();
              return false;
          }
          return dbFile.exists();
      }
  </code></pre>