This approach utilizes the Web component for handling database operations.
Core Logic
1. Dynamic Request Builder
A procedure (test_Firebase) dynamically:
- Constructs the Firebase URL using:
- Bucket (Project Path)
- Tag
- Appends
.jsonto match Firebase REST format - Chooses the request type based on a Type parameter:
1 → GET2 → PUT (Store)3 → PATCH (Update)4 → DELETE
2. CRUD Operations
- GET → Retrieves data from Firebase
- PUT → Stores new data or overwrites existing data
- PATCH (simulated via PUT) → Updates existing data
- DELETE → Removes a specific tag
3. Response Handling
- Checks
responseCode = 200for success - Handles responses based on request type:
- GET
- If data exists → JSON decoded and displayed
- If
null→ shows no data
- PUT → “Data saved successfully”
- PATCH → “Data updated successfully”
- DELETE
null→ success- otherwise → failure
- GET
- Displays errors when request fails
4. User Interface Flow
- Separate buttons for:
- Get
- Store
- Delete
- Inputs:
- Bucket (database path)
- Tag (key)
- Value (for storing/updating)
- Screen switching system:
- Toggles between Get / Put / Delete views
- Clears inputs when switching screens
5. Data Handling
- Ensures Firebase-compatible format:
- Uses JSON encoding/decoding
- Prevents crashes by:
- Checking for
"null"responses before decoding
- Checking for
