Office Hours — Today, June 10

Tuesday, June 8

Jun 10
8:55 AM
Mark M.
has entered the room
Mark M.
turned on guest access
9:30 AM
CalvinS
has entered the room
Justin M.
has entered the room
Mark M.
howdy, CalvinS and Justin M!
Justin M.
Hey there Mark :-)
Mark M.
I leave my desk for two minutes, and a crowd rolls in!
Justin M.
Quiet day today?
Mark M.
up until now
Justin M.
I totally forgot earlier to come on in, I have some stuff to ask you about database persistence, but I'll wait until CalvinS is done, I think he got here before I did
Mark M.
yeah, I think he beat you by a few seconds
so, Calvin, do you have a question?
CalvinS
Hi there....Go ahead Justin I'm just being a fly on the wall until I have questions
Justin M.
OK cool, here goes...
So we're looking at database persistence right now for our app, and I was thinking I'd be able to do what we're doing in our iPhone app, have model classes that are the middlemen between the UI and the database...
But as I've been digging into database persistence on Android, like with SQLiteOpenHelper, it's seeming like I can't have that kind of separation since it needs to know about the Context from the Activity...
Mark M.
yeah, Android isn't big on having smart model classes
9:35 AM
Mark M.
though the Context issue isn't particularly a large issue
avoiding tons of data copying on query results (out of a Cursor, into models) is a bigger problem
Justin M.
I've looked at the Notepad example from developer.android.com and it is really basic, but it looks like the DbAdapter class basically is the goto man for all database access. With one table that wouldn't be too bad, but we're going to have several, it just seems like a bulky solution
We also have parent-child relationships in the database that would be nice to hide in model classes. What do you think is the best way to tackle this? Hope I gave enough information here
Mark M.
well, there's nothing limiting you to one such class
on Android, particularly until 2.2 and JIT become widespread, I am hesitant to recommend smart model objects
been there, done that, hit myself repeatedly with a ballpeen hammer in the process
I would put your smarts more in the controllers
(thinking of MVC)
(though MVP and presenters might be a better pattern -- always blur those in my mind)
Justin M.
So having DbAdapters for each table perhaps? Am I understanding you correctly?
Mark M.
something along that line
they can help somewhat with 1:N relations and all
9:40 AM
Mark M.
yet allow you to keep your data in ordinary Cursors
Justin M.
OK, and then after retrieve the cursors, then in the Activity where I'm going to display the data, manage linking up the two tables together by managing two cursors for the two tables?
I'm a little hazy this morning, hope I'm making sense :-P
Mark M.
I was about to ask for clarification of that last one
I seem to be lacking a sentence subject :-)
my hope is that an individual activity will tend to be simpler
for example, take the 1:N relation between recipe and ingredient
a recipe view activity would certainly need to list the ingredients
however, it really should only do that for one recipe, not a whole cookbook
so you may have two Cursors, but one will be a single-row Cursor (the recipe) and the other will be detail info (the ingredients)
Justin M.
OK, I think that makes sense. Do you know of any examples/projects where there is some more complex database interaction and 1:N relationships that are implemented that I might be able to take a look at, that might be a good place to look too, and then I can come back with some better, more specific questions for next time?
Mark M.
none that I've looked at the source code for
so, for example, some OpenIntents apps should have more complex database models than Notepad
9:45 AM
Mark M.
however, I haven't looked at their code to see how they do it
the code that I've done for this was under contract and is not publicly viewable
Justin M.
Yeah, I wish Google had better examples on this subject. I would think that lots of people would need to know about that.
Mark M.
I suspect the fabled Twitter app will make for interesting reading
once they release it
sometime before Ft. Lauderdale freezes over
Justin M.
LOL that happens about once every 15 years or so (I know, I used to live there ;-) )
Mark M.
only been there once
all I remember are flying cockroaches the size of small cars
:-)
Justin M.
LOL, yeah, you can thank the Everglades for that :-P
Well, at least you helped me decide to stop going down the path of the smart model objects, I'll dig around some more and hopefully have some better questions next week. You'll get to see all of the fruits of my labor in a month ;-)
9:50 AM
Justin M.
So I'm good for now, thanks!
Mark M.
you're welcome!
Oh real quick, the OpenIntents you talked about, is that http://www.openintents.org?
Mark M.
yes
Justin M.
OK, I'll look at that then, thanks :-)
Mark M.
ShoppingList, NewsReader, etc. should all have more complex database models
Justin M.
Cool beans
9:55 AM
CalvinS
I have a question now
Mark M.
go right ahead!
CalvinS
how do you use the icons in the android resources directory you told me about Tuesday...they are all XML files
the ones here for example F:\android-sdk-windows\platforms\android-8\data\res
Mark M.
well, not all of them are XML files
the ones in res/drawable/ are mostly XML files -- StateListDrawable, LevelListDrawable, etc.
the ones in res/drawable-hdpi/ and res/drawable-mdpi/ are PNGs, mostly
for the PNGs, just copy them
if you do need, say, a StateListDrawable, you will need to copy the XML and the PNGs it refers to, then possibly modify your copy of the XML to point to your copy of the PNGs
once they are in your project's res/ tree, though, you refer to them no different than any other resource (e.g., R.drawable.foo, @drawable/foo)
10:00 AM
CalvinS
k thanks!
Mark M.
aaaaaaaaaaaaaaaaaaaand, that's a wrap for today's chat
two next week, both in the evening, as I am teaching a class during East Coast business hours
CalvinS
Have a good one guys!
Mark M.
a bit outside of Decidedlywarmlanta
Justin M.
OK, take care!
HOTlanta :-)
CalvinS
has left the room
Justin M.
has left the room
Mark M.
turned off guest access

Tuesday, June 8

 

Office Hours

People in this transcript

  • CalvinS
  • Justin Munger
  • Mark Murphy