Office Hours — Today, March 21

Saturday, March 18

Mar 21
3:55 PM
Mark M.
has entered the room
Mark M.
turned on guest access
4:15 PM
Fabio M.
has entered the room
Mark M.
hello, Fabio!
how can I help you today?
Fabio M.
hi mark :)
Mark M.
do you have a question?
Fabio M.
Yes, i'm a beginner and i'm starting to work on db access trough sqlite. I read your chapter and tutorial on this matter. My concern is about what is the best way to implement the db access through a single activity and multiple fragments requiring db access.
4:20 PM
Mark M.
I would have some sort of data manager class be the access point to the database
Fabio M.
Is it better to setup a class db helper which calls fragment through callbacks or implementing asynctask in fragments?
Mark M.
I would lean towards using your first option
have a centralized class that handles your data access, threading, caching, etc.
the activity can set up the instance of that class and make it available to the fragments
Fabio M.
Ok just as you did in the epublite?
So, in general,is better using Threads instead of asynctask for db access
Mark M.
in EmPubLite, I went with the model fragment approach
in a single-activity app, a model fragment might be fine for your data access
sorry, let me rephrase that
in EmPubLite, I demonstrated two approaches
for the main EmPubLite activity, I used a model fragment for data access, though in that case it was not SQLite, but book information
for the notes, I delegated the threading and data access to the DatabaseHelper subclass of SQLiteOpenHelper
in both cases, the UI-related classes (the activity and regular fragments) did not handle threading or the actual I/O
4:25 PM
Mark M.
whether you use regular threads or AsyncTask or RxAndroid or something else is really up to you
Fabio M.
Ok, think i got it :)
Mark M.
they each have their pros and cons
Fabio M.
Ok, thanks a lot for your time. Keep up with this work, i'ma really happy subscriber
Mark M.
you are very welcome!
Fabio M.
Have a nice day
Mark M.
you too!
4:40 PM
Fabio M.
has left the room
4:55 PM
Albert
has entered the room
Mark M.
hello, Albert!
how can I help you today?
Albert
hi. thanks. i don't have a specific question today. just thought i'd check in to the chat room and see how it works. haven't visited this before.
Mark M.
mostly, the chat room is lightly populated
Albert
not sure -- is that an ok way to participate?
Mark M.
people ask questions, then head out
Albert
ah. ok.
Mark M.
you can see transcripts of past chats at: https://commonsware.com/office-hours/
5:00 PM
Albert
thanks. i'll take a look at those then. best regards.
Mark M.
I'll be posting the transcript from today's chat (somebody was here earlier) shortly
FWIW, the next chat is tomorrow at 7:30pm US Eastern
but, for now, that's a wrap for today's chat -- I gotta get back to absorbing the O Developer Preview :-)
have a pleasant day!
Albert
ok. thanks. that's good to know. (i'm on west coast, fwiw).
you too.
Albert
has left the room
Mark M.
turned off guest access

Saturday, March 18

 

Office Hours

People in this transcript

  • Albert
  • Fabio Moretti
  • Mark Murphy