There's just one final thing I want to mention before we finish the app.
In the emulator, I'll enter a new task with the name
aaa and the description aaaa,
then save.
The task aaa appears below most of the other tasks in the list,
allowing for the sort order column.
So it appears after task 5.
This may not be what users expect.
The reason is that our sort is case-sensitive.
In most collations lowercase letters sort after uppercase.
But that's not true of some character sets such as Cyrillic, for example.
So if you're using Cyrillic, then you'll have to do a lot more research.
I'm assuming you're using a character set that sorts lowercase
after uppercase.
The solution to this problem is to add the SQL
collate no case clause
that we saw in the SQL tutorial part in this section.
I'll call up the documentation for the ContentProvider's Query method
in TaskTimerViewModel's load tasks section.
The description of the sort order parameter is the useful one.
The parameter is formatted as a SQL order by clause,
excluding the order by.
So we can add the no case collation to the sort order string
on line 91.
It's important to put a space before the word collate.
We'll edit the comment above so it matches.
I put the order by in angle brackets because we don't include that
but it's useful to see the complete SQL clause.
I'll stop the app on the emulator
because android studio's InstantRun feature
can sometimes work against us when doing things like this.
It tries to avoid restarting the app,
which here would mean that the view model doesn't re-query the database.
So if you don't get the result you expect when running your app,
make sure to stop it first.
When I run the app now,
the aaa task appears at the start of the list
where a user would expect it.
Google have added two extra collation sequences to SQLite on android,
unicode and localized
If your character set isn't handled correctly by no case,
then you may want to try one of those instead.
There's documentation available here.
If you want to use those collations, remember they're specific to android.
The unicode and localized collations won't work when you use the sqlite3
program on your computer.
You'll need to test your SQL in a shell on your emulator.
All right. That's the app finished, and the end of this section.
In the next section, we'll look at what's involved
when you want to deploy an app to the Google Play Store.
I'll see you there.