r/androiddev • Atlassian • Nov 29 '17

Don't forget to inject Android Room SQL language for syntax highlight and autocomplete!

Post image
215 Upvotes

21 comments sorted by

5

u/la__bruja Nov 29 '17

What color scheme is it? Also great tip, never thought it's possible

3

u/deinlandel Nov 29 '17

Does it also handle actual database column names etc? I've never figured out how to hook up device database explorer to Android Studio

2

u/dmytrodanylyk Atlassian Nov 29 '17

Does it also handle actual database column names etc? Yes

1

u/benol Android Studio Team Nov 29 '17

Completion inside @Query is currently based on the "Room schema" as defined by entity classes. We don't maintain a connection to the device.

18

u/leonce18 Nov 29 '17

I actually have never used Room, but this screenshot itself is enough to get me on it :)

8

u/benol Android Studio Team Nov 29 '17

You also get go-to-definition (ctrl-click) from columns and tables to classes and fields. Renaming the class rewrites SQL, you can also right click a table name to rename the class etc. (there are some limitations).

This feature is a lot smarter in 3.1 canaries if you're curious.

1

u/MrBIMC Nov 29 '17

OMG that's so epic.

Modern tooling never ceases to amaze me.

5

u/nohe427 Nov 29 '17

Didn't know about this. Neat!

3

u/Noclue93 Nov 30 '17

ill be switching to room when this works in kotlin. goodbye realm!

2

u/Plazmaz1 Nov 29 '17

I read 'SQL' and 'Inject' in the same sentence and those this was /r/netsec for a second there...

1

u/CodeToDeath Nov 29 '17

What does the AndroidDataBinding option do? (I'm using data binding. So curious to know about this option and how to use it)

2

u/benol Android Studio Team Nov 29 '17

It's the language injected into XML attributes when using data binding. You should have no need to ever inject it manually.

1

u/[deleted] Nov 29 '17

Woah, neat! I remember wondered about such feature. Didn't know that it already existed. Thanks!

-1

u/ZakTaccardi Android Developer Nov 29 '17

AdminDao > AdminDAO.

Why does this matter? XMLHttpRequest

ps: this feature of Room is awesome!

1

u/MrBIMC Nov 29 '17

Second variant is actually against official kotlin code-style.

1

u/ZakTaccardi Android Developer Nov 29 '17

And Google style

18

u/[deleted] Nov 29 '17

[removed] — view removed comment

5

u/dmytrodanylyk Atlassian Nov 29 '17

Yes

9

u/benol Android Studio Team Nov 29 '17

It's https://youtrack.jetbrains.com/issue/KT-13636. We're trying to fix it in upstream Kotlin.

1

u/liuwenhao Nov 29 '17

Would love to see this fixed! Glad it's on the Android team's radar.