code: public static int crapToDisk(Context ctx, String filename, byte[] data){
          int code = IO_FAIL;
  
          File dir = Environment.getExternalStorageDirectory();
          File output = new File(dir, filename);
          try {
              FileOutputStream fos = new FileOutputStream(output);
              try {
                  fos.write(data);
                  code = IO_SUCCESS;
              } catch (IOException e) {
                  code = IO_FAIL;
              } finally {
                  fos.close();
              }
  
          } catch (IOException e) {
              e.printStackTrace();
          }
  
          return code;
      }
docs: Dump Data straight to the SDCard
  
  @param ctx           the application context
  @param filename      the dump filename
  @param data          the data to dump
  @return              the return