4

On a string literal, Android studio offers the inject language feature, but in the drop down list of languages, there is no SQL offered. All the documentation states it should be there. Any idea how I can inject SQL?

enter image description here

naXa stands with Ukraine
  • 35,493
  • 19
  • 190
  • 259
Steve Waring
  • 2,882
  • 2
  • 32
  • 37

2 Answers2

6

There is a Database Navigator plugin, which offers similar functionality.

Supported Databases:

Language injection feature:

SQL languages

This tool is free for personal and commercial usage. Donations are very welcome though. (I'm not affiliated nor associated with authors)

naXa stands with Ukraine
  • 35,493
  • 19
  • 190
  • 259
2

Database tools and SQL support are only available in IntelliJ IDEA Ultimate.

Source

Hence, you cannot use SQL support in Android Studio.

You could use ADB Shell to connect to SQLite, which is IDE independent.

Community
  • 1
  • 1
Darek Kay
  • 15,827
  • 7
  • 64
  • 61
  • I wonder why then this page https://developer.android.com/sdk/installing/studio-tips.html states: Injecting languages With language injection, the Android Studio IDE allows you to work with islands of different languages embedded in the source code. This extends the syntax, error highlighting and coding assistance to the embedded language. This can be especially useful for checking regular expression values inline, and validating XML and SQL statements. – Steve Waring May 17 '15 at 15:09
  • Also, this page https://www.jetbrains.com/idea/help/accessing-android-sqlite-databases-from-intellij-idea.html makes no mention of Ultimate when it states: If your application uses an Android SQLite database, you can access this database right from IntelliJ IDEA through a data source of the Android SQLite type. – Steve Waring May 17 '15 at 15:21
  • And this page https://www.jetbrains.com/idea/help/android-support-overview.html states Android support in IntelliJ IDEA includes:..... Access to SQLite Databases right from the IDE. – Steve Waring May 17 '15 at 15:24
  • My best guess - it's an error in the Android documentation. The IntelliJ Web Help doesn't mention this explicitly, because the whole Database support is Ultimate only. This is confirmed in the comments of this [blog post](http://blog.jetbrains.com/idea/2013/10/intellij-idea-13-eap-and-android-sqlite-database/). This also applies to your last comment - IntelliJ Android Support is not equal to Android Studio. – Darek Kay May 17 '15 at 15:25
  • Oh dear. I have recently switched from Eclipse to Android Studio after reading four reviews that said there were no drawbacks with moving. No access to Android SQLite is a big downside I guess I will have to port the code back into Eclipse and write off to experience the week I have spent getting used to the new IDE. – Steve Waring May 17 '15 at 16:09
  • This post does show how to access the database from the command line, so all is not lost: http://stackoverflow.com/questions/17529766/see-database-filecontent-via-android-studio though the SQL injection would have been very helpful. – Steve Waring May 17 '15 at 16:28
  • @SteveWaring I think it's a bug in the documentation, I have submitted [an issue](https://code.google.com/p/android/issues/detail?id=177271). – naXa stands with Ukraine Jun 16 '15 at 12:05