---
name: "al_android_open_fd"
section: "3alleg5"
platform: "linux"
package: "allegro5-doc"
version: "2:5.2.10.1+dfsg-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/al_android_open_fd/3alleg5"
---

# al\_android\_open\_fd(3alleg5)

Allegro 5 API

## NAME

al\_android\_open\_fd - Allegro 5 API

## SYNOPSIS

-

  ```
  #include <allegro5/allegro_android.h>
  int al_android_open_fd(const char *uri, const char *mode)
  ```

## DESCRIPTION

Opens a file descriptor to access data under a Universal Resource Identifier (URI). This function accepts content:// and file:// URI schemes. You are responsible for closing the returned file descriptor.

The file `mode` can be `"r"`, `"w"`, `"rw"`, `"wt"`, `"wa"` or `"rwt"`. The exact implementation of these modes differ depending on the underlying content provider. For example, `"w"` may or may not truncate.

Returns a file descriptor on success or a negative value on an error. On an error, the Allegro errno is set.

*Note:* Remember to add to your manifest file the relevant permissions to your app.

Example:

-

  ```
  const char *content_uri = "content://...";
  int fd = al_android_open_fd(content_uri, "r");
  if (fd >= 0) {
      ALLEGRO_FILE *f = al_fopen_fd(fd, "r");
      if (f != NULL) {
          do_something_with(f);
          al_fclose(f);
      }
      else {
          handle_error(al_get_errno());
          close(fd);
      }
  }
  else {
      handle_error(al_get_errno());
  }
  ```

## SINCE

5\.2.10

## SEE ALSO

al\_fopen\_fd(3alleg5), al\_get\_errno(3alleg5)

*\[Unstable API\]:* This API is new and subject to refinement.
