SimpleSQLProvider


Source link: https://github.com/ckurtm/simple-sql-provider

SimpleSQLProvider

The Fastest Way to create a sql based ContentProvider in Android using annotations (No reflection)

HOW TO ADD TO YOUR PROJECT

Gradle:

add the apt plugin as a dependency to your root build gradle as below:

buildscript {

  repositories {

jcenter()
  
}

  dependencies {

classpath 'com.android.tools.build:gradle:1.3.0'

classpath 'com.neenbedankt.gradle.plugins:android-apt:1.6'
  
}
 
}

apply the apt plugin to your main project's build.gradle

apply plugin: 'com.neenbedankt.android-apt'

add the required dependencies as below

dependencies {

compile 'com.squareup:javapoet:1.2.0'

compile 'ckm.simple:simple_sql_provider_annotation:1.0.6'

compile 'ckm.simple:simple_sql_provider_processor:1.0.6' 
}

QUICK START

  1. Create ProviderConfig class that defines your content providers details e.g.
 @SimpleSQLConfig(

 name = "TestProvider",

 authority = "just.some.test_provider.authority",

 database = "test.db",

 version = 1)  public class TestProviderConfig implements ProviderConfig {

@Override

public UpgradeScript[] getUpdateScripts() {

 return new UpgradeScript[0];

}
  
}

This class file says - Create a ContentProvider called TestProvider - The authority for this Provider is "just.some.test_provider.authority" - The Provider uses a database file named "test.db" - The Current database version is 1 - provider UpdateScripts as a defined by the UpdateScripts class

  1. Annotate your Pojo file that defines a table in the Database as below.
  @SimpleSQLTable(table = "test", provider = "TestProvider")
public class Test {

 @SimpleSQLColumn("col_str")
public String myString;
 @SimpleSQLColumn(value = "col_int", primary = true)
public int anInt;
 @SimpleSQLColumn("col_integer")
public int myinteger;
 @SimpleSQLColumn("col_short")
public int myshort;
 @SimpleSQLColumn("col_short2")
public int myShort;
 @SimpleSQLColumn("col_long")
public long mylong;
 @SimpleSQLColumn("col_long2")
public int myLong;
 @SimpleSQLColumn("col_double")
public long mydouble;
 @SimpleSQLColumn("col_double2")
public int myDouble;
 @SimpleSQLColumn("col_float")
public long myfloat;
 @SimpleSQLColumn("col_float2")
public int myFloat;
 @SimpleSQLColumn("col_bigdecimal")
public BigDecimal bigD;
 @SimpleSQLColumn("col_bool")
public boolean mybool;
 @SimpleSQLColumn("col_bool2")
public boolean myBool;
 @SimpleSQLColumn("col_date")
public Date mydateCol;

}

 ```  3. The rebuild your project  4. You will now have access to files generated for you to access the Table prefixed with "Table" using the usual Android ContentProvider methods, e.g. TestTable for the above class.
 The generated files have convinience functions for you to add values to the table, e.g. getContentValues() with an instance of the Test class to insert into db e.g.

  ```java
 Test testInstance = new Test(...);

 getContentResolver().insert(TestTable.CONTENT_URI,TestTable.getContentValues(testInstance,false));

 ```

  To get data from the database use:

  ```java

 Cursor cursor = getContentResolver().query(TestTable.CONTENT_URI,null,null,null,null);

 //one row

 Test testRow = TestTable.getRow(cursor,true);

 //multiple rows

 List<Test> testRows = TestTable.getRows(cursor,false);

 ```

  5. add your provider as usual to your AndroidManifest.xml file with a matching authority as defined in ProviderConfig class

  ```xml

  <provider

  android:authorities="just.some.test_provider.authority"

  android:name="example.kurt.test.TestProvider"/>

 ```
 ##License  Apache License (Version 2.0)  You may not use this file except in compliance with the License. You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Resources

FlxBox2D is a wrapper for Box2D through libgdx. The Box2D is a full JNI wrapper which means there's no garabage collection issues at all and the JNI call overhead is minimal.

Android-Icon-Fonts project contains material and Holo iconic fonts.

Manual ProGuard configuration is not a pleasant task. It requires a lot of time, patience and strong Google-fu to search dark corners of Internet for magic incantations that make ProGuard happy and don't screw up your build. A bottle of alcoholic beverage also comes in handy.

We just want to say "ProGuard this for me, please". And that's what this plugin strives to do.

If you do any serious Android development, you've probably used ProGuard to obfuscate, optimise and shrink your application. In that case it's also very likely that ProGuarding your app has broken your release builds, took a few hours of your time away while pulling your hair out.

Squad leader includes two annotations that you can add to your code to specify that you want to @Keep a class, method or field and it's name. There's also a @KeepName annotation that does the same, but only if the annotated element is actually used in your code.

Android library for detecting and reporting long running SQLite queries.

If some of your queries takes longer than the threshold specified in the CerberusCursorFactory constructor, the report containing the offending query, elapsed query time, stack trace, and the result of EXPLAIN QUERY PLAN sqlite query will be dumped into the logcat.

Intel XDK HTML5 Cross-platform Development Tool provides a simplified workflow to enable developers to easily design, debug, build, and deploy HTML5 web and hybrid apps across multiple app stores, and form factor devices.

Experience Intel XDK - the easy and fast way to get your apps to market.

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