mitmel / simplecontentprovider Goto Github PK
View Code? Open in Web Editor NEWA simple ContentProvider for Android
Home Page: http://mobile.mit.edu/
License: Other
A simple ContentProvider for Android
Home Page: http://mobile.mit.edu/
License: Other
I guess I'm nitpicking.
example/SampleProvider.java#SampleProvider()
// the above three statements can be repeated to create multiple data
// stores. Each will have separate tables and URIs.
There's only two statements above (not including the constuctor). I guess at some point there were more.
It would be great, if i can create multicolumn unique. A made a workaround by created a new ColumnType.
The current example does a great job of demonstrating how to use ContentItem
and SimpleContentProvider
. It would be great to add an example of using foreign keys in there.
<provider
android:name="SampleProvider"
android:authorities="edu.mit.mobile.android.content.example.sampleprovider"
/>
In the example project's manifest, the name is given as SampleProvider
. How does this work without pre-pending the name with a period to indicate that the application package should be used?
The guidelines found on developer.android.com (http://developer.android.com/guide/topics/manifest/provider-element.html) indicate that the name attribute should be fully qualified, or the first character should be a period.
In the example project, everything is under one package.
I'm asking because my application's package name is different from the package my Provider is in (the manifest is the Only place where the old package name is used, to allow updates for existing users).
The comment for the String constant in SampleProvider in the example project says:
// Each ContentProvider must have a globally unique authority. You should
// specify one here starting from your Application's package string:
Is it the case that it's required to start from that package string, or just that it's the practice? Under the "Designing an Authority" section on developer.android.com (http://developer.android.com/guide/topics/providers/content-provider-creating.html), it says "should" append application package name, though from the context of the paragraph, looks like it's just to avoid naming conflicts, rather than any technical reason.
There isn't an easy way to support data migration between db revisions. This should be added, possibly by way of subclassing.
In SimpleContentProvider
there should be a protected getter for mDatabaseHelper
so that subclasses can access the database directly if they need to.
m2m is great, but one2many is often what one needs. Parts of the current m2m tried to be o2m, so that needs to be fixed.
The harder part about o2m (considering the current framework) is that it requires the ability to change the table creation for the target object. This may require creating a special column type.
The _id field is the last in table. It is not issue, but a bit annoying.
Adding/dropping columns are pretty common in doing DB work. It'd be really cool if there was some infrastructure to assist with automatic generation of table migration SQL.
One of the hard parts about this with the current model is that it would probably involve introspection using SQLite-specific commands to compare table definitions.
InsertHelper can improve performance by up to 2x by optimizing query generation. Use this for bulkInsert (if it makes sense to do so).
Currently, it's not possible to have one path of the provider backed by something other than the database, even though that should be possible. Ideally, one could have - say - a contact photo URI go straight to a filesystem instead of a database. This will require a bit of refactoring and maybe changing of the API, but is one of the goals for this framework.
To demonstrate this functionality, a simple filesystem path handler should be written which allows for storage / retrieval of content from a file, probably by returning a URI instead of the binary blob itself (it may be valuable to check out the way that Android implements the contact provider for this).
To help show that the library is as modern as the latest version of Android, the example should use the ActionBar model instead of a ButtonBar model for its activities. While the compatibility library doesn't actually provide support for using ActionBars, https://github.com/johannilsson/android-actionbar/tree/mimic-native-api provides a good one that mimics the native API.
The existing ManyToMany helper provides basic functionality, but there is a lot of room for improvement. It's not entirely easy to discover and use the relationship between tables and how to construct appropriate URLs for querying parent/children.
It would probably be a good idea to look deeper at what Django and Hibernate provide in terms of this and see what can be done while still sticking to the URI-centric worldview and ContentProvider API.
It'd be nice if it would be possible to create virtual paths in the same content provider that aren't backed by SQLite databases. For example, one could have a thumbnail resource that's backed by a filesystem. This extension could possibly include a simple file-backed provider for saving binary blobs.
When i'm using "insert ignore" or "unique on conflict ignore" the insert throws exception, because of the rowid = -1 in GenericDBHelper at line ~ 120 (insertDir). The solution is simple: remove throwing and simple return null.
It should handle all the query processing and wrap existing query processors somehow.
http://developer.android.com/intl/de/guide/topics/search/adding-custom-suggestions.html
// this is called when the activity is re-started by the system with a new intent. This is only
// really used with the
In SimpleContentProviderExample#onNewIntent(Intent)
the method comment is incomplete. I haven't felt this way since finishing Harry Potter 6.
Currently, there's no support for for bulk inserts or any other bulk operations. This can be extremely helpful for performance and should be added.
This should support the bulkInsert() and applyBatch() functions, wrapping any DB calls in a transaction to ensure it's atomic.
using defaultValue = DatetimeColumn.NOW_IN_MILLISECONDS
as well as flags = DatetimeColumn.FLAG_AUTO_NOW
doesn't yield atomic setting of the column values.
Test 2 failed with created / modified being off by 1ms. Ideally these should be exactly the same.
This would be very handy for folks building with Maven or Gradle. :)
Provide an example that demonstrates M2M being used. Perhaps People/Project ?
As the future of Android is the Loader model, we should either move the current example to the Loader framework (using the compatibility library) or provide an example that demonstrates the use of the new framework.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.