Is it possible to execute a raw query in an Android meta sqlite Android database?

I am writing a small music playback application. My goal is Android API 7 and above.

The application should only display and play music marked with a specific set of genres selected by the user through settings, for example. Pop, Rock, Hillbilly.

Now I'm trying to find an effective way to find all album identifiers and album names containing tracks marked with selected genres.

It is easy in SQL. The phone stores multimedia metadata in a sqlite database. I found it on the phone’s internal memory, copied it using adb and tried some SQL queries on it. The resulting query is a single-line SQL code with a connection chain and works fine.

This seems more complicated in Java with the Android SDK, at least with API level 7 and above. I can use managedQuery on MediaStore to do some limited SQL syntax in the same base database, but if I get things right, then using this API there will be no JOIN and DISTINCT.

Also, I might have missed this, but MediaStore allows me to search all tracks of one genre, but not for all tracks of several genres in a single query.

So this all works a bit in Java. Now the program needs to make several managedQuery () calls for each genre, and the program should join the results and make them different from java, outside sqlite (where this work belongs).

Is this really the way it should be done? Can't just send a raw query to sqlite database file?

Thanks!

+6
source share
1 answer

No, you cannot directly access the basic structure of the database - in fact, you do not have the opportunity to find out the actual structure of the database, it has changed in versions of the platform. The only direct requests you can make are those that are provided through the MediaStore protocol of the content provider.

+2
source

Source: https://habr.com/ru/post/909684/


All Articles