Office Hours — Today, December 12

Thursday, December 10

Dec 12
8:55 AM
Mark M.
has entered the room
Mark M.
turned on guest access
Michael W.
has entered the room
Mark M.
hello, Michael!
how can I help you today?
Michael W.
Good Morning, Mark
What is pro cons of using ORM vs the 'traditional' SQLite?
Mark M.
since I haven't used one of the Android ORMs yet, I can only answer this based upon what I have seen and read, not personal experienc
er, experience
in general, an ORM is designed to make it easier for you to write your database logic
the cost, to varying degrees, will be runtime performance
ORMs that focus more on compile-time code generation, such as using Gradle plugins, have the potential for better runtime performance
9:00 AM
Michael W.
Which ORM that focus on compile-time code generation?
Mark M.
I have no idea specifically
there are a lot of them nowadays
I hope to get more into ORMs in 2016, along with NoSQL options
Michael W.
Did it handle the schema change when upgrading the app?
Mark M.
that's usually an objective of an ORM, though not all would necessarily provide it as a feature
the biggest thing is letting you deal with normal-looking Java objects, as opposed to having to mess with Cursor, ContentValues, etc.
9:05 AM
Michael W.
Actually I'm ok with the Cursor, etc, but thinking will be a little bit difficult to handle schema change
Mark M.
that depends on the complexity of the schema and how frequently you change it
it certainly can be a headache
Michael W.
Is it true that let say if the schema now is v5, so we have to handle case of upgrade from v1 -> v5, v2 -> v5, v3->v5, v4->v5?
Mark M.
yes, at least in terms of end result
users are not forced to take on all app updates
and you might issue schema-changing updates quickly, for various reasons
however, a common pattern to reduce the effort on your part is one-at-a-time upgrading
once upon a time, you only had v1, and no upgrade logic
when you created v2, you wrote v1->v2 migration code
when you create v3, you clearly need v2->v3 migration code
for v1 users, you can either write custom v1->v3 migration code, or simply use your existing v1->v2, followed by v2->v3
and so on
9:10 AM
Michael W.
Yes that's why I'm thinking that it would be headache, although I've never had that experience
Still related to the DB design, I read on the tutorial on the net that use UUID
Is the standard ID not enough?
Mark M.
usually, a UUID is used when the data needs to be synchronized with a server, or in other cases where more than one client is generating an ID
for an app working only with its local data, a UUID is overkill
9:15 AM
Michael W.
So, it's better to have the UUID generated on the server side only right?
Mark M.
not necessarily
the idea behind a UUID is that nobody else should be likely to generate the same one
it used to be tied to MAC addresses
nowadays, it's just random numbers, but a long enough chain of them that there is little likelihood of collision
Michael W.
Okay I just knew it, since I thought that it's only a random number
And there's still a chance of collision
Mark M.
the same chance occurs if they are all generated on the server
UUID generators don't somehow magically check all other UUIDs for collision
you'd have to implement your own logic to confirm that you have not used that UUID before
that's certainly doable, of course
the old MAC address approach also used a timestamp, and I don't think the timestamp is used anymore in the UUID generation algorithms
Michael W.
Yes, thanks Mark, will look more into the UUID generation on the Android..
Is there any chance to intercepting SMS in the Android?
Mark M.
define "intercepting"
9:20 AM
Michael W.
For example I want user to verify the mobile number
Mark M.
well, you can try to *monitor* SMS messages, by watching for SMS_RECEIVED broadcasts
Michael W.
Gateway will send SMS starting with 'VERIFY' to the user, and then the app will intercept the SMS if the SMS start with 'VERIFY', checking into it, and if it's true, then just delete the SMS
Mark M.
that will be unreliable on Android 4.4 and below, and outright impossible on Android 5.0+ (unless you are the actual SMS client app)
you may be better served having them send the SMS with a unique code, rather than receive it
you can send the SMS using SmsManager without user involvement, if you have the SEND_SMS permission
Michael W.
Yes, it's can be done also, maybe whatsapp did something like this, although the user will charge for the SMS fee
9:25 AM
Michael W.
Another topic that still bothered me is how if I want to delete an item on the list (on the RecyclerView), and user will see it's animated
Mark M.
"see it's animated" -- you mean you want it to slide or fade or something when being deleted?
if yes, there are default animations already applied
and you can customize them if you wish
Michael W.
Like the item will hide away (sliding from its position to the right), and the items under that item will going up
Mark M.
that specific animation is the default, IIRC
(or maybe it's a fade, then the items beneath it slide up, I forget)
see the SortedList demo in my RecyclerView chapter
9:30 AM
Michael W.
I didn't try that because I think it's only sort the list
Mark M.
it also happens to demonstrate the animation effect, for inserts
it's just using the default animation, no customization
Michael W.
Okay, I'm trying the project
Actually I'm still not trying any option, but do the ripple effect can be applied when user click the item on the list?
Mark M.
I forget if I use the ripple in that particular demo, but I have others that do (see CardRippleList3, for example)
9:35 AM
Michael W.
So the effect for the card will apply to the standard list, right?
Mark M.
I am sorry, but I do not understand that question
Michael W.
The ripple is used for the CardView on the demo, and will apply also on the RecyclerView?
Mark M.
um, well, the RecyclerView itself does not really have a UI
so, no, the ripple on a card affects the card
tapping a card will not cause all cards to ripple, or cause one single RecyclerView-wide ripple
9:40 AM
Michael W.
Yes, that's what I mean :-) thanks Mark
If I want to put a large DB on the apps, what is the limitation, or is it depend on the user device?
9:45 AM
Michael W.
Regarding the RAM, what's mostly cause the app took large portion of RAM?
Mark M.
with respect to a large database, your primary limitation will be the user's patience and willingness to spend bandwidth in downloading the database
and I do not know exactly what you mean by "large portion of RAM"
Michael W.
Sometimes user will see on the Application Manager and see the Running process
As a user, I usually will stop the app that consume large memory
Mark M.
partly, that is your heap space; partly, that is your code, including NDK libraries
and, if you are using NDK libraries, partly that is NDK-allocated system RAM
9:50 AM
Mark M.
since Android will terminate processes to free up system RAM, doing so yourself ahead of time is usually not that helpful
instead, you should be figuring out why that big process is still around in the first place
with respect to your own app, the #1 thing that keeps your process around is a running service
Michael W.
Actually since what I heard about NDK is doing C++ on the Android so I skip the chapter about that :-D
Mark M.
which is why you should only have a service running when it is actively delivering value to the user: https://commonsware.com/blog/2014/07/27/role-se...
note that you may be using third-party libraries that are themselves using the NDK
SQLCipher for Android is one example
my CWAC-AndDown library is another
Michael W.
Thanks Mark, will look further into that one
Let say I have a book that consist of thousand pages.. So the recommended way is to save them to the SQLite right?
Mark M.
not necessarily
my book is 3400+ pages, and while I use SQLite, that is only for the FTS3 table for full-text searching
the book contents itself are simple HTML files in assets/
9:55 AM
Michael W.
If I want to make it encrypted, using SQLite is better?
Mark M.
unless the user is providing the encryption passphrase, encrypting it will be pointless
SQLite itself does not do encryption; SQLCipher for Android is a version of SQLite that offers encryption
Michael W.
I see.. I firstly thought that I will create my own encryption
Thanks for pointing out the SQLCipher
If the bottleneck is the user patient on downloading, how to set like the progress bar when downloading the assets/database?
Or is there any tutorial that you recommend on the net?
Mark M.
use an HTTP client library that gives you a spot to register a callback for progress, then update the UI as you go (whether that UI is an activity or a Notification)
Michael W.
Okay thanks Mark
10:00 AM
Mark M.
and that's a wrap for today's chat
the transcript will be posted to https://commonsware.com/office-hours/ shortly
the next chat is Tuesday at 4pm US Eastern
have a pleasant day!
Michael W.
has left the room
Mark M.
turned off guest access

Thursday, December 10

 

Office Hours

People in this transcript

  • Mark Murphy
  • Michael W