easy-content-providers


Source link: https://github.com/EverythingMe/easy-content-providers

Easy Content Providers

Easy integration with Android's built-in and custom content providers data. It even comes with a Sample app and Stetho extension for debugging purposes.

Why and When

We often experiment with new features, new apps, new ideas or we just code through a hackathon project that's built on-top of Android's content providers.. In such cases, we need tools to get what we want with minimum friction. This is where easy-content-providers come in - we can get all android stored data very easily and we can debug results through Chrome dev tools (based on Stetho implementation).

The library uses reflection and some additional operations to make the ORM implementation generic, this is great for flexibility and POCs but might not be sufficient for high performance production apps. Also, if you don't define the exact columns you want, the mapping will happen on all columns (select * from ...). Sometimes, this is not what you want.

Example Usage

Gradle:

dependencies {

  compile 'me.everything:providers-android:1.0.1' 
}
 

Getting all calendars:

CalanderProvider provider = new CalendarProvider(context);
 List<Calendar> calendars = provider.getCalendars().getList();

Full documentation can be found at the wiki.

Inspecting provider data

Gradle:

dependencies {

  compile 'me.everything:providers-stetho:1.0.1'  
}
 

Leveraging Stetho's ability to inspect SQLite databases, you can visualize, explore and modify all provider data.

In the above example, all providers can be seen expanded, "provider-calendar" is selected and it's items appear in the table to the right.

Adding your own providers

And of course, you can see your own providers by registring them. In our example (check sample app):

...  providersStetho.registerProvider("provider-custom", "posts", new ProvidersStetho.QueryExecutor<Post>() {

  @Override
  public Data<Post> onQuery(String query) {

PostsProvider provider = new PostsProvider(getApplicationContext());

return provider.getPosts();

  
}
 
}
);
  ...

Which looks like so:

SQL Quering

Stetho allows to query SQLite databases from within it's console. Currently, Android providers are interactable with sql, with the following limitations:

  • Only all-inclusive queries are possible select * from "tablename"

  • Results may take a few seconds to appear.

  • Querying tables in provider-calendar can only be done like so:

    • #events:id=3 - select from events where calendar id = 3
    • #instances:id=100 - select from instances where event id = 100
    • #reminders:id=100 - select from reminders where event id = 100
    • #attendees:id=100 - select from attendees where event id = 100

We are inclined to rid ourselves of these limitations. Stay tuned for upcoming developments.

Sample App

Try it out with our sample app. Download the apk, run it on a connected device, open chrome://inspect in Chrome and start inspecting the providers to your delight.

Notice the app lists items from each provider. Take a look at the app's source code to see how this was implemented.




Author

Roman Kushnarenko - sromku

License

Apache License 2.0

Resources

This is an Android project allowing to realize a beautiful circular fillable loaders to be used for splashscreen for example.

Scoop is a micro framework for building view based modular Android applications.

Android view centring RecyclerView.

Rx based generic RecyclerView adapter library.

Screen adaptation library for Android.

An implementation of a floating search box with search suggestions.

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