I've produced a ContentProvider for my primary Sqlite table, virtually following NotePad example from SDK (although I don't know whether I'll be subjecting my data with other applications). However, I have to create all, non-trivial queries on might other tables and sights. An example could be queries to extract some statistics in the base data, earnings, totals etc.

So what's where with this code within an Android project? How it ought to be related and attached to the Uri-based data access uncovered with a Provider? Worthwhile good examples available?

From the purpose of look at maintainabillty I believe the provider model may be the cleanest method to abstract the information access code. And from experience getting done a sizable application, eventually the applying will grow to the stage where some data should be uncovered through the provider model (e.g. presenting services towards the application). Nevertheless subjecting a variety of sights of the data could be a large amount of operate in the provider model.

Should you go the path I'd be cautious the way you uncovered the information through Web addresses, in most cases a few of the complexity you talk of could be handled with utilization of sub-sites representing different sights from the data (much like a Relaxation approach).

If you want to prevent the provider model, then applying a DA class is rather easy. Typically a SQLiteOpenHelper is creatd being an inner class towards the DA class (outdoors assistant also companies fundamental versioning support) and a clear case of these kinds can be used to produce database connections within the DA functions. You will find many good examples within the Android Source code. Take a look at the provider implementations, with MediaProvider.java most likely being probably the most relevant because it uses quite complex looks for a provider. For instance in the source code that's not really a content provider see DbSSLSessionCache.java

In case your information is just being utilized because of your application then I recommend missing this content provider altogether. It is because, it'll add unnecessary layers involving the application and also the DB which will not help performance.

I suggest writing a category whose only job would be to update/query the database. Then out of your other classes/activities you are able to instantiate this DB access class to obtain data or put data.

You could have multiple cases of your DB class running at the same time.

Edit: Sample code clips (I required the course definition along with a couple techniques from the working code) It had been my first application, so it is not perfect, however it works:

public class VoyagerDB extends SQLiteOpenHelper {
    @Override
    public void onCreate(SQLiteDatabase db) {
            boolean ret = false;

            // build out the schema
            ret = populateSchema(db);

    }


    /**
     * Returns information from a given obdRequest record.
     * @param requestID
     * @return
     */
    public Cursor getRequestInfo (String requestID) {

            Cursor c = null;

            String sql = "SELECT id _id, active,request,formula, description,frequency,minValue,maxValue,numDataBytes " +
                            "FROM obdRequest " +
                            "WHERE ID=" + requestID;

            c = localDBRW.rawQuery(sql, null);

            return c;
    }


    /**
     * If the given settings key exists in the DB, return its record ID. Otherwise return blank.
     * @param key
     * @return
     */
    public String settingsKeyExists (String key) {
            String recordID = "";
            Cursor c = null;

            String sql = "SELECT id,key,value from settings WHERE key = ?";
            String selectionArgs[] = {key};
            c = localDBRW.rawQuery(sql, selectionArgs);

            if (c == null) {
                    return "";
            }
            if (c.getCount()<1) {
                    c.close();
                    return "";
            }

            c.moveToFirst();
            recordID = c.getString(c.getColumnIndex("id"));
            c.close();

            return recordID;
    }

}