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!
|
Mark M. |
how can I help you today?
|
Michael W. |
Good Morning, Mark
|
Michael W. |
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
|
Mark M. |
er, experience
|
Mark M. |
in general, an ORM is designed to make it easier for you to write your database logic
|
Mark M. |
the cost, to varying degrees, will be runtime performance
|
Mark M. |
ORMs that focus more on compile-time code generation, such as using Gradle plugins, have the potential for better runtime performance
|
Dec 12 | 9:00 AM |
Michael W. |
Which ORM that focus on compile-time code generation?
|
Mark M. |
I have no idea specifically
|
Mark M. |
there are a lot of them nowadays
|
Mark M. |
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
|
Mark M. |
the biggest thing is letting you deal with normal-looking Java objects, as opposed to having to mess with Cursor, ContentValues, etc.
|
Dec 12 | 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
|
Mark M. |
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
|
Mark M. |
users are not forced to take on all app updates
|
Mark M. |
and you might issue schema-changing updates quickly, for various reasons
|
Mark M. |
however, a common pattern to reduce the effort on your part is one-at-a-time upgrading
|
Mark M. |
once upon a time, you only had v1, and no upgrade logic
|
Mark M. |
when you created v2, you wrote v1->v2 migration code
|
Mark M. |
when you create v3, you clearly need v2->v3 migration code
|
Mark M. |
for v1 users, you can either write custom v1->v3 migration code, or simply use your existing v1->v2, followed by v2->v3
|
Mark M. |
and so on
|
Dec 12 | 9:10 AM |
Michael W. |
Yes that's why I'm thinking that it would be headache, although I've never had that experience
|
Michael W. |
Still related to the DB design, I read on the tutorial on the net that use UUID
|
Michael W. |
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
|
Mark M. |
for an app working only with its local data, a UUID is overkill
|
Dec 12 | 9:15 AM |
Michael W. |
So, it's better to have the UUID generated on the server side only right?
|
Mark M. |
not necessarily
|
Mark M. |
the idea behind a UUID is that nobody else should be likely to generate the same one
|
Mark M. |
it used to be tied to MAC addresses
|
Mark M. |
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
|
Michael W. |
And there's still a chance of collision
|
Mark M. |
the same chance occurs if they are all generated on the server
|
Mark M. |
UUID generators don't somehow magically check all other UUIDs for collision
|
Mark M. |
you'd have to implement your own logic to confirm that you have not used that UUID before
|
Mark M. |
that's certainly doable, of course
|
Mark M. |
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..
|
Michael W. |
Is there any chance to intercepting SMS in the Android?
|
Mark M. |
define "intercepting"
|
Dec 12 | 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)
|
Mark M. |
you may be better served having them send the SMS with a unique code, rather than receive it
|
Mark M. |
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
|
Dec 12 | 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?
|
Mark M. |
if yes, there are default animations already applied
|
Mark M. |
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
|
Mark M. |
(or maybe it's a fade, then the items beneath it slide up, I forget)
|
Mark M. |
see the SortedList demo in my RecyclerView chapter
|
Dec 12 | 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
|
Mark M. |
it's just using the default animation, no customization
|
Michael W. |
Okay, I'm trying the project
|
Michael W. |
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)
|
Dec 12 | 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
|
Mark M. |
so, no, the ripple on a card affects the card
|
Mark M. |
tapping a card will not cause all cards to ripple, or cause one single RecyclerView-wide ripple
|
Dec 12 | 9:40 AM |
Michael W. |
Yes, that's what I mean :-) thanks Mark
|
Michael W. |
If I want to put a large DB on the apps, what is the limitation, or is it depend on the user device?
|
Dec 12 | 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
|
Mark M. |
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
|
Michael W. |
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
|
Mark M. |
and, if you are using NDK libraries, partly that is NDK-allocated system RAM
|
Dec 12 | 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
|
Mark M. |
instead, you should be figuring out why that big process is still around in the first place
|
Mark M. |
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...
|
Mark M. |
note that you may be using third-party libraries that are themselves using the NDK
|
Mark M. |
SQLCipher for Android is one example
|
Mark M. |
my CWAC-AndDown library is another
|
Michael W. |
Thanks Mark, will look further into that one
|
Michael W. |
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
|
Mark M. |
my book is 3400+ pages, and while I use SQLite, that is only for the FTS3 table for full-text searching
|
Mark M. |
the book contents itself are simple HTML files in assets/
|
Dec 12 | 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
|
Mark M. |
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
|
Michael W. |
Thanks for pointing out the SQLCipher
|
Michael W. |
If the bottleneck is the user patient on downloading, how to set like the progress bar when downloading the assets/database?
|
Michael W. |
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
|
Dec 12 | 10:00 AM |
Mark M. |
and that's a wrap for today's chat
|
Mark M. |
the transcript will be posted to https://commonsware.com/office-hours/ shortly
|
Mark M. |
the next chat is Tuesday at 4pm US Eastern
|
Mark M. |
have a pleasant day!
|
Michael W. | has left the room |
Mark M. | turned off guest access |