Skip to content

iagolirapasssos/EnhancedDB

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EnhancedDB: Advanced SQLite Extension for MIT App Inventor

EnhancedDB is a powerful Java-based extension for MIT App Inventor that provides a robust and flexible alternative to the built-in TinyDB. It allows developers to work with multiple SQLite tables, perform efficient data operations, and import/export data as JSON — all without requiring external servers or internet access.


✨ Features

  • 🗃️ Multiple tables with dynamic switching
  • 💾 Persistent local storage using SQLite
  • 🏷️ Key-value storage (with key existence check)
  • 📥 JSON export and import
  • ⚡ Optimized for performance and large data sets
  • 🔐 Safe and simple CRUD operations
  • 🔧 Easy integration with App Inventor blocks

📦 Installation

  1. Clone or download this repository.
  2. Compile the .java file into an .aix extension using your preferred build tool (Ant, App Inventor Sources, or Fast CLI).
  3. Import the .aix into your MIT App Inventor project via Extensions > Import extension.

🧱 App Inventor Blocks Overview

Block Description
InitializeDB(name) Initializes or opens an SQLite database with the given name.
SetTable(name) Sets or creates a table for data operations.
SetValue(tag, value) Saves or updates a value associated with a tag.
GetValue(tag, default) Retrieves a value by tag or returns default if not found.
Exists(tag) Checks if a tag exists.
GetAllKeys() Returns a list of all tags in the current table.
Remove(tag) Deletes the specified tag.
ClearDB() Clears all entries in the current table.
ExportDB() Returns all data as a JSON string.
ImportDB(json) Imports data from a JSON string.

🔧 Developer Notes

Requirements

  • JDK 8 or later
  • App Inventor annotations (appinventor-annotations.jar)
  • Android SDK
  • SQLite (built-in in Android)

Core File

The main class is EnhancedDB.java. It extends AndroidNonvisibleComponent and uses SQLiteOpenHelper to manage database operations locally.

Example: Creating a New Table

@SimpleFunction(description = "Sets the active table name. Creates it if needed.")
public void SetTable(String tableName) {
    this.currentTable = tableName;
    db.execSQL("CREATE TABLE IF NOT EXISTS " + currentTable + " (tag TEXT PRIMARY KEY, value TEXT);");
}

Releases

No releases published

Packages

No packages published

Languages