android-sqlite-model-generator-plugin


Source link: https://github.com/sromku/android-sqlite-model-generator-plugin

SQLite Model Generator

Eclipse plugin - Generate SQLite model for Android based on JSON schema file

Usage of the plugin

1. Install the plugin

Update site: http://romkuapps.com/Apps/SQLite/update

2. Create JSON file that describes your sqlite schema.

  • Schema has name and tables
  • table has name, description and columns
  • column has name and columnType
  • columnType can be TEXT or INTEGER only

Example: Two tables: STUDENT and COURSE

{

"name": "SQL_PRIVATE_DB",
"tables": [
  {

 "name": "STUDENT",

 "description": "Student details",

 "columns": [

{

  "name": "FIRSTNAME",

  "columnType": "TEXT"

}
,

{

  "name": "LASTNAME",

  "columnType": "TEXT"

}
,

{

  "name": "AGE",

  "columnType": "INTEGER"

}

 ]
  
}
,
  {

 "name": "COURSE",

 "description": "Course details",

 "columns": [

{

  "name": "NAME",

  "columnType": "TEXT"

}
,

{

  "name": "COURSENUMBER",

  "columnType": "INTEGER"

}
,

{

  "name": "DESCRIPTION",

  "columnType": "TEXT"

}
,

{

  "name": "POINTS",

  "columnType": "INTEGER"

}

 ]
  
}

] 
}

3. Right click on the file -> 'Generate SQLite Model...'

4. Refresh the project

Generated Code

Entities

Each table is converted to Java entity and is generated under 'entities' package

| - entities 

Actions

Each entity can be creates, updated, deleted or retrieved from the database. The support for CRUD actions is located under 'actions' package

  | - actions
 | - create
 | - delete
 | - read
 | - update 

Model

The entry point for all operations above SQLite database are done via Model.java class, which is located under 'model' package

 | - model  

Usage

Create

For each defined table in the JSON file you can create a new entity which will be saved in the SQLite table

 Student student = new Student();
  student.setFirstname("John");
  student.setLastname("Smith");
  student.setAge(30);

  Model model = Model.getInstance(context);
  model.createStudent(student);

Retrieve

For each defined table in the JSON file you can retrieve all entities from that SQLite table

 Model model = Model.getInstance(context);
  List<Student> students = model.readStudent();

Update

For each defined table in the JSON file you can update existing entity from the SQLite table

 student.setAge(31);

 Model model = Model.getInstance(context);
  model.updateStudent(student);

Delete

For each defined table in the JSON file you can delete existing entity from the SQLite table

 Model model = Model.getInstance(context);
  model.deleteStudent(student);

How it works

  • The first time the singleton instance of the model is created Model model = Model.getInstance(context), all the SQLite database content is loaded into the memory.
  • Each of CRUD commands works directly with the cached data and SQLite database. For example, model.update...(Object object) will update the entity in the memory and then update the raw in the database. Thus, the database is always synced.

Resources

Following the same approach that RxActivityResult does, RxPermissionsResult is a reactive wrapper around the permission's Android Api, which allows to get the data without breaking the observable chain.

You don't want your apps look and feel boring, do you? Add some bubbles!

This custom view is structured of Sine Wave Equation.

CheckableView library that features Button and ImageButton to work as a checkable view components.

An extension of RelativeLayout that helps show loading, empty and error layout.

This is a simplified library to track the user location and address corresponding to it.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes