{
  "id": "android/sqlite-cursor-column-type-mismatch",
  "signature": "android.database.sqlite.SQLiteException: Cannot read from cursor: column 'price' has type REAL but expected INTEGER (code 0)",
  "signature_zh": "android.database.sqlite.SQLiteException：无法从游标读取：列 'price' 的类型是 REAL，但期望的是 INTEGER（代码 0）",
  "regex": "android\\.database\\.sqlite\\.SQLiteException: Cannot read from cursor: column '.*' has type REAL but expected INTEGER",
  "domain": "android",
  "category": "data_error",
  "subcategory": null,
  "root_cause": "Cursor attempts to read a REAL column as INTEGER via getInt(), causing type mismatch in SQLite's dynamic typing system.",
  "root_cause_type": "generic",
  "root_cause_zh": "游标尝试通过 getInt() 将 REAL 列读取为 INTEGER，导致 SQLite 动态类型系统中的类型不匹配。",
  "versions": [
    {
      "version": "Android 11 (API 30)",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Android 12 (API 31)",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Android 13 (API 33)",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Cast the column value to int in SQL query: `CAST(price AS INTEGER)`",
      "why_fails": "This truncates decimals, losing precision; the real fix is to read as getDouble().",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "Change column type in CREATE TABLE to INTEGER",
      "why_fails": "SQLite is dynamically typed; the column type only affects affinity, not actual stored values. Existing data remains REAL.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    },
    {
      "action": "Use getString() and parse to int",
      "why_fails": "Parsing '12.99' to int throws NumberFormatException or truncates incorrectly.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Use `cursor.getDouble(cursor.getColumnIndexOrThrow(\"price\"))` instead of getInt() to read REAL columns correctly.",
      "success_rate": 0.95,
      "how": "Use `cursor.getDouble(cursor.getColumnIndexOrThrow(\"price\"))` instead of getInt() to read REAL columns correctly.",
      "condition": "",
      "sources": []
    },
    {
      "action": "In Room, annotate the field as `Double` (not Int) in the entity class: `@ColumnInfo(name = \"price\") val price: Double`",
      "success_rate": 0.92,
      "how": "In Room, annotate the field as `Double` (not Int) in the entity class: `@ColumnInfo(name = \"price\") val price: Double`",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use `cursor.getType(columnIndex)` to check the type before reading: if type == Cursor.FIELD_TYPE_FLOAT, use getDouble(); else getInt().",
      "success_rate": 0.85,
      "how": "Use `cursor.getType(columnIndex)` to check the type before reading: if type == Cursor.FIELD_TYPE_FLOAT, use getDouble(); else getInt().",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Use `cursor.getDouble(cursor.getColumnIndexOrThrow(\"price\"))` instead of getInt() to read REAL columns correctly.",
    "In Room, annotate the field as `Double` (not Int) in the entity class: `@ColumnInfo(name = \"price\") val price: Double`",
    "Use `cursor.getType(columnIndex)` to check the type before reading: if type == Cursor.FIELD_TYPE_FLOAT, use getDouble(); else getInt()."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://developer.android.com/reference/android/database/sqlite/SQLiteException",
  "official_doc_section": null,
  "error_code": "SQLiteException code 0",
  "verification_tier": "ai_generated",
  "confidence": 0.88,
  "fix_success_rate": 0.92,
  "resolvable": "true",
  "first_seen": "2023-11-20",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}