Create File / Dir
Summary
- Internal name:
CreateDir - Category: File System
- Purpose: Create a file or a directory (recursively) inside the AndroMate file sandbox.
- Task type: Normal
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 Create File / Dir task creates either a file or a directory, depending on the selected type. Parent directories are created recursively if needed.
All File System tasks are confined to the AndroMate sandbox: /sdcard/AndromateFileTask. A relative path is resolved inside the sandbox; an absolute path must stay within it. Any attempt to escape the sandbox (e.g. with ../) is rejected with FILE-TASK-001. The sandbox directory is created automatically on first use.
Input parameters
| Parameter | Type | Required | Possible values / Rules | Android Compatibility | AndroMate Compatibility | Default |
|---|---|---|---|---|---|---|
create_type |
Enum / String | No | Directory or File |
Android 13 (API 33) → Android 16 (API 36) | 1.1.0 → 1.1.0 | Directory |
file_path |
String | Yes | Path inside the sandbox (supports interpolation) | Android 13 (API 33) → Android 16 (API 36) | 1.1.0 → 1.1.0 | "" |
Output parameters
This task produces no output variable. It returns a VoidResult on success.
Exceptions
| Code | Trigger condition |
|---|---|
FILE-TASK-001 |
Path is outside the AndroMate sandbox |
FILE-TASK-002 |
File system operation failed (I/O error) |
Execution flowchart
flowchart TD
Start([▶ CreateDir]) --> Jail[📂 Ensure sandbox exists]
Jail --> Validate{Path inside sandbox ?}
Validate -->|No| Throw([❌ FILE-TASK-001])
Validate -->|Yes| Type{Type ?}
Type -->|File| MkFile[📄 createFile]
Type -->|Directory| MkDir[📁 createDir]
MkFile --> Success([✅ VoidResult])
MkDir --> Success
style Start fill:#e3f2fd
style Success fill:#c8e6c9
style Throw fill:#ffcdd2
style Jail fill:#fff9c4
style Validate fill:#fff9c4
How it works:
- Sandbox: the sandbox directory is created if missing
- Validate: the resolved path is checked to be inside the sandbox (anti path-traversal)
- Create: a file (
createFile) or directory (createDir) is created, parents included - Result: returns
VoidResult
Code examples
Example 1 — Create a directory
{
"CreateDir": [
{
"id": "1",
"title": "Create reports folder",
"create_type": "Directory",
"file_path": "reports/2026"
}
]
}
Example 2 — Create an empty file
{
"CreateDir": [
{
"id": "2",
"title": "Create log file",
"create_type": "File",
"file_path": "logs/result.log"
}
]
}
Input parameter details
create_type — What to create
Directory→ creates a folder (recursively)File→ creates an empty file (parent folders created if needed)
file_path — Target path
Path inside the sandbox. A relative path (reports/2026) is resolved under /sdcard/AndromateFileTask. Supports $variable interpolation.
Output parameter details
This task produces no output variable.