java - 如何在Android中使用Settings.Global、Settings.Secure和Settings.System?

标签 java android

我想使用上面提到的类,并想从它们的静态常量中检索信息。我想检索这样的信息。例如来自 Settings.Secure

SETTINGS_SECURE
ADB_ENABLED=1
ALLOWED_GEOLOCATION_ORIGINS=http://www.google.co.uk 
ALLOW_MOCK_LOCATION=0
ANDROID_ID=200142d4dfd4e641

但我实际上得到了这个输出:

SETTINGS_SECURE
ADB_ENABLED=adb_enabled
ALLOWED_GEOLOCATION_ORIGINS=allowed_geolocation_origins
ALLOW_MOCK_LOCATION=allow_mock_location
ANDROID_ID=android_id

有什么建议吗?

最佳答案

看起来您只是在检索常量的值。作为一个简单的例子来说明差异,产生上述输出:

StringBuilder sb = new StringBuilder("SETTINGS_SECURE\n");

sb.append(Settings.Secure.ADB_ENABLED.toUpperCase())
    .append("=")
    .append(Settings.Secure.getString(getContentResolver(),
        Settings.Secure.ADB_ENABLED))
    .append("\n")

    .append(Settings.Secure.ALLOWED_GEOLOCATION_ORIGINS.toUpperCase())
    .append("=")
    .append(Settings.Secure.getString(getContentResolver(),
        Settings.Secure.ALLOWED_GEOLOCATION_ORIGINS))
    .append("\n")

    .append(Settings.Secure.ALLOW_MOCK_LOCATION.toUpperCase())
    .append("=")
    .append(Settings.Secure.getString(getContentResolver(),
        Settings.Secure.ALLOW_MOCK_LOCATION))
    .append("\n")

    .append(Settings.Secure.ANDROID_ID.toUpperCase())
    .append("=")
    .append(Settings.Secure.getString(getContentResolver(),
        Settings.Secure.ANDROID_ID));

关于java - 如何在Android中使用Settings.Global、Settings.Secure和Settings.System?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22496157/

相关文章:

java - 使用 Hibernate ConstraintViolationException

java - 将面板放在 JLabel 背景之上 (Java)

Google 的 Android 代码加上在一个 Activity 中登录并从另一个 Activity 中注销

java.util.MissingFormatArgumentException : Format specifier: s

java - 如何重新抛出异常

java - 如何将 java String 转换为邮寄地址对象?

java - 如何将 excel 文件中的字符串分解为子字符串并加载它?

android - 如何通过 ListView 和刷新 ListView 从 SQLite 数据库中删除一行?

java - 使用 maven 为库项目导出 jar 的正确方法是什么?

android - 如果我从我的 Android 应用程序中排除所有 64 位库,它是否会完全以 32 位模式运行?