Office Hours — Today, February 1

Tuesday, January 29

Feb 1
3:50 PM
Mark M.
has entered the room
Mark M.
turned on guest access
4:35 PM
EGHDK
has entered the room
Mark M.
howdy, EGHDK!
how can I help you today?
EGHDK
View paste
Hey Mark,

I was thinking about this today and wanted to quickly pick your brain about it.
4:40 PM
Mark M.
only so long as you put my brain back when you're done
EGHDK
Alright, so last time we were talking and we discussed that it's possible to take a db using adb from a non-rooted device correct?
Mark M.
um
adb backup, for apps that allow backups, can back up a database without root
and your app can copy your database file to external storage without root
EGHDK
How would an app go about "allowing" a backup?
Mark M.
I think it's allowed by default
android:allowBackup on the <application> element controls is
there's a new Lint warning for you to be explicit about allowing/blocking backups
EGHDK
Oh alright. So I'll look into "allowBackup". Thanks
4:45 PM
EGHDK
My next question is more of a "how would you go about this" type of question.
I have a sqlite database of baseball players and their stats. What would be the best way to bake this into my application so people can access it while offline, but also check for updates online?
Mark M.
if by "bake in" you mean you want to ship a pre-populated database with your app, use SQLiteAssetHelper
also covered in the book
EGHDK
Do I include it in the application, and then run some code on startup to move the file into /data/data/com.test.baseball/baseball_db?
Mark M.
yes, and that's what SQLiteAssetHelper does for you
4:50 PM
EGHDK
Coolio. Great, and one last thing. Would it be smart to delete the original sqlite db after it's been imported with SQLiteAssetHelper?
Mark M.
you can't
if it is baked into your app, it's there forever
you cannot modify an APK at runtime
EGHDK
Even if it's a raw directory?
Mark M.
well, it won't be with SQLiteAssetHelper
but resources and assets are read-only
they cannot be modified or removed from the APK at runtime
5:00 PM
Mark M.
and that's a wrap for today's chat
the transcript will be posted shortly to http://commonsware.com/office-hours/
the next chat is Thursday at 4pm
have a pleasant day!
EGHDK
has left the room
Mark M.
turned off guest access

Tuesday, January 29

 

Office Hours

People in this transcript

  • EGHDK
  • Mark Murphy