sqlite-analyzer


Source link: https://github.com/novoda/sqlite-analyzer

sqlite-analyzer

Code generation for Java/Android database access.

Description

Generates java/android database access code by analysing sqlite migration files or sqlite databases, keeping full control of what code is generated.

sqlite-analyzer creates an in-memory sqlite database, either from a given database file or by reading sql migrations, and analyzes its tables to construct a DatabaseModel. This model is then used to generate database access code.

This project uses sqlite-jdbc to create and analyze the database. Groovy is used to generate code, Gradle to hook the functionality into the android build system.

Adding to your project

To integrate sqlite-analyzer into your project, add the following at the beginning of the build.gradle of your project:

buildscript {

  repositories {

jcenter()
  
}

  dependencies {

classpath 'com.novoda:sqlite-analyzer:0.3.2'
  
}
 
}

To use the library with sqlite-provider, add these lines to the build.gradle of your project:

apply plugin: 'com.novoda.sqlite-analyzer'  sqliteAccess {

  migrationsDir 'src/main/assets/migrations'
  packageName 'com.novoda.sqliteprovider.demo.simple' 
}

See the sample projects for setup with android-sqlite-asset-helper.

Simple usage

Try ./gradlew clean assembleDebug and observe the generated code under build/generated/source/sqlite/debug/.

By default, it contains one single class DB that defines constants for the names of the tables and columns and introduces static accessor methods as well as model classes for all tables data.

The project comes with 2 demo applications that create and use database access code, one uses sqlite-provider, the other uses android-sqlite-asset-helper.

Use column names

queryBuilder.appendWhere(DB.Columns.Shop.Name + " like 'A%'")

Simplified use with static import

projection = new String[] {
Employees.Firstname, Employees.Lastname
}
;

Use model classes

public void onLoadFinished(Loader<Cursor> cursorLoader, Cursor cursor) {

  DB.Shop shop = DB.Shop.fromCursor(cursor);
 
}

Use helpers for ContentValues

ContentValues values = new ContentValues(1);
 DB.Shop.setName("New Shop", values);

Links

Here are a list of useful links:

  • We always welcome people to contribute new features or bug fixes, here is how
  • If you have a problem check the Issues Page first to see if we are working on it
  • For further usage or to delve more deeply checkout the Project Wiki
  • Looking for community help, browse the already asked Stack Overflow Questions or use the tag: support-sqlite-analyzer when posting a new question

Resources

FlowLayoutManager is a layoutManager that works with Android RecyclerView Widget to layout views in flow style with support of predictive animations, item per line limit, auto measurement & alignments (left or right).

This project is responsible for app downloading and installation process.

Android Library that shows a customizable Material-based bottom sheet.

A cool loading view with Bezier and a smooth circular motion.

A toolkit help to build Android MVVM Application.

Native ItemTouch helper swipe and drag support for RecyclerView with undo action just like in "Do It" app.

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