Search code examples
androidadb

android shell content query error


I'm trying to get system settings using content query command. For example:

adb shell content query --uri content://settings/system --projection name:value --where "name='user_rotation'"

Returns with following error

Error while accessing provider:settings
android.database.sqlite.SQLiteException: no such column: user_rotation (code 1): , while compiling: SELECT name, value F
ROM system WHERE (name=user_rotation)
        at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:181)
        at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:137)
        at android.content.ContentProviderProxy.query(ContentProviderNative.java:420)
        at com.android.commands.content.Content$QueryCommand.onExecute(Content.java:535)
        at com.android.commands.content.Content$Command.execute(Content.java:417)
        at com.android.commands.content.Content.main(Content.java:605)
        at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
        at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:251)

I could get all the entries though with,

adb shell content query --uri content://settings/system

Solution

  • I ran into a similar error and found that escaping the inner quotes resolved my issue. Try changing --where "name='user_rotation'" to this --where 'name=\"user_rotation\"'.

    Here's what your updated command should look like:

    adb shell content query --uri content://settings/system --projection name:value --where 'name=\"user_rotation\"'
    

    Hope this helps.