Skip to content

File Exists

Summary

  • Internal name: FileExists
  • Category: File System
  • Purpose: Check whether a file or a directory exists at the given path. Branches the workflow: true if it exists, false otherwise.
  • Task type: Condition

Compatibility

  • Minimum AndroMate version: 1.1.0

  • Maximum AndroMate version: 1.1.0

  • Minimum Android: Android 13 (API 33)

  • Maximum Android tested: Android 16 (API 36)

  • Required permissions: MANAGE_EXTERNAL_STORAGE


Detailed description

The File Exists task checks the presence of a path on the device file system using File.exists(). It acts as a condition node: the workflow branches to the true path if the file or directory exists, and to the false path otherwise.

The check returns true for both files and directories — it only tells you whether the path is present, not its type.


Input parameters

Parameter Type Required Possible values / Rules Android Compatibility AndroMate Compatibility Default
file_path String Yes Path to a file or directory (supports interpolation) Android 13 (API 33) → Android 16 (API 36) 1.1.0 → 1.1.0 ""

Output parameters

This is a Condition task — it does not store a value. Instead, it directs workflow execution:

Condition Next step
The path exists (file or directory) true branch
The path does not exist false branch

Exceptions

This task does not throw exceptions. A missing path routes to the false branch.


Execution flowchart

flowchart TD
    Start([▶ FileExists]) --> Resolve[🔧 Resolve file_path]

    Resolve --> Check[📁 File.exists]

    Check --> Exists{Exists ?}

    Exists -->|Yes| TrueBranch([✅ true branch])
    Exists -->|No| FalseBranch([❌ false branch])

    style Start fill:#e3f2fd
    style TrueBranch fill:#c8e6c9
    style FalseBranch fill:#ffcdd2
    style Check fill:#fff9c4

How it works:

  1. Resolve: the file_path is resolved against the AndroMate context
  2. Check: File.exists() is evaluated
  3. Branch: exists → true branch; otherwise → false branch

Code examples

Example 1 — Branch on a config file presence

{
  "FileExists": [
    {
      "id": "1",
      "title": "Config exists ?",
      "file_path": "/sdcard/AndromateFileTask/config.json"
    }
  ]
}

Input parameter details

file_path — Path to check

Absolute path to a file or directory. Supports $variable and ${SPECIAL_VAR} interpolation. The check succeeds for both files and directories.


Output parameter details

This is a Condition task — it stores no output variable. The result drives the workflow branching (true / false).


Complete JSON example

{
  "FileExists": [
    {
      "id": "1",
      "title": "File Exists",
      "file_path": "/sdcard/AndromateFileTask/logs/result.log"
    }
  ]
}