@Override
    protected String doInBackground(Void... params) {
      DriveHelper helper = new DriveHelper(mGoogleApiClient);
      StringBuilder result = new StringBuilder();
      MetadataBuffer buffer =
          Drive.DriveApi.getAppFolder(mGoogleApiClient)
              .listChildren(mGoogleApiClient)
              .await()
              .getMetadataBuffer();
      try {
        result
            .append("found ")
            .append(buffer.getCount())
            .append(" file(s):")
            .append(EOL)
            .append("----------")
            .append(EOL);

        for (Metadata m : buffer) {
          DriveId id = m.getDriveId();
          result.append("Name: ").append(m.getTitle()).append(EOL);
          result.append("MimeType: ").append(m.getMimeType()).append(EOL);
          result.append(id.encodeToString()).append(EOL);
          result.append("LastModified: ").append(m.getModifiedDate().getTime()).append(EOL);
          String content = helper.getContentsFromDrive(id);
          result.append("--------").append(EOL).append(content).append(EOL);
          result.append("--------");
        }
      } catch (IOException io) {
        result.append("Exception fetching content").append(EOL);
      } finally {
        buffer.close();
      }
      return result.toString();
    }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main22);
    ed = (EditText) findViewById(R.id.editText2);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    googleApiClient = MainActivity.getGoogleApiClient();
    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    id = DriveId.decodeFromString(getIntent().getExtras().getString("id"));
    text = "";
    final DriveFile df = id.asDriveFile();
    final Lectura llig = new Lectura();

    llig.execute(df);

    while (!isReaded) {
      if (text == "") {

      } else {
        ed.setText(text);
        isReaded = true;
      }
    }
    final Escritura escriu = new Escritura();

    fab.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            Toast.makeText(getApplicationContext(), "Actualitzant...", Toast.LENGTH_SHORT).show();
            escriu.setText(ed.getText().toString());

            escriu.execute(df);

            Toast.makeText(getApplicationContext(), "Actualitzat!", Toast.LENGTH_SHORT).show();
            finishActivity(RESULT_OK);
          }
        });

    ResultCallback<DriveApi.DriveContentsResult> contentsOpenedCallback =
        new ResultCallback<DriveApi.DriveContentsResult>() {
          @Override
          public void onResult(DriveApi.DriveContentsResult result) {
            if (!result.getStatus().isSuccess()) {

              // display an error saying file can't be opened
              return;
            }
            // DriveContents object contains pointers
            // to the actual byte stream
            DriveContents contents = result.getDriveContents();
          }
        };

    PendingResult<DriveApi.DriveContentsResult> opened =
        df.open(googleApiClient, DriveFile.MODE_READ_WRITE, null);
    opened.setResultCallback(contentsOpenedCallback);
  }