Patches Cursor#getColumnIndex(String) to work around issues on older devices. If the column is not found, it retries with the specified name surrounded by backticks. @param c The cursor. @param name The name of the target column. @return The index of the column, or -1 if not found.
(@NonNull Cursor c, @NonNull String name)
| 89 | * @return The index of the column, or -1 if not found. |
| 90 | */ |
| 91 | public static int getColumnIndex(@NonNull Cursor c, @NonNull String name) { |
| 92 | int index = c.getColumnIndex(name); |
| 93 | if (index >= 0) { |
| 94 | return index; |
| 95 | } |
| 96 | index = c.getColumnIndex("`" + name + "`"); |
| 97 | if (index >= 0) { |
| 98 | return index; |
| 99 | } |
| 100 | return findColumnIndexBySuffix(c, name); |
| 101 | } |
| 102 | |
| 103 | /** |
| 104 | * Patches {@link Cursor#getColumnIndexOrThrow(String)} to work around issues on older devices. |
no test coverage detected