Faber Fedor wrote:
>     What *is* magic is that there is a public static final Uri named
>     CONTENT_URI, and that this Uri is the base Uri for your provider, and
>     that it begins with content://.
> 
> I must be missing something since that doesn't seem magical to me.

Sorry. By "magic" I mean it has to be named CONTENT_URI and have the
properties as listed. If you decided you didn't want to call it
CONTENT_URI, it probably wouldn't work.

> I thought onCreate() was a constructor,
> i.e. whenever my app initialized and/or created an object, onCreate()
> would be called.

Java has its own constructors. onCreate() is a callback used by some
Android classes.

> It turns out the onCreate() is called if the datastore
> doesn't exist.

There are lots of onCreate() callbacks. I'm assuming you're referring to
the SQLiteOpenHelper, whose onCreate() documentation says: "Called when
the database is created for the first time."

> I say that because I kept dropping my table in SQLite but the
> ContentProvider.onCreate() was never called until I deleted the database
> from the hard drive.

Correct. The more conventional approach, on schema changes, is to
increment the version number of the database (fourth parameter to
SQLiteOpenHelper constructor), which will trigger an onUpgrade() call to
your SQLiteOpenHelper object.

> I assume all onCreates()s act similarly.

For SQLiteOpenHelper implementations, yes.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com
_The Busy Coder's Guide to Android Development_ Version 1.9 Available!

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to