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.
- 🗃️ 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
- Clone or download this repository.
- Compile the
.javafile into an.aixextension using your preferred build tool (Ant,App Inventor Sources, orFast CLI). - Import the
.aixinto your MIT App Inventor project via Extensions > Import extension.
| 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. |
- JDK 8 or later
- App Inventor annotations (
appinventor-annotations.jar) - Android SDK
- SQLite (built-in in Android)
The main class is EnhancedDB.java. It extends AndroidNonvisibleComponent and uses SQLiteOpenHelper to manage database operations locally.
@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);");
}