{"action":"closed","issue":{"url":"https://api.github.com/repos/SecUpwN/Android-IMSI-Catcher-Detector/issues/549","labels_url":"https://api.github.com/repos/SecUpwN/Android-IMSI-Catcher-Detector/issues/549/labels{/name}","comments_url":"https://api.github.com/repos/SecUpwN/Android-IMSI-Catcher-Detector/issues/549/comments","events_url":"https://api.github.com/repos/SecUpwN/Android-IMSI-Catcher-Detector/issues/549/events","html_url":"https://github.com/SecUpwN/Android-IMSI-Catcher-Detector/issues/549","id":95032238,"number":549,"title":"Using wrong type of SQL queries","user":{"login":"E3V3A","id":194392,"avatar_url":"https://avatars.githubusercontent.com/u/194392?v=3","gravatar_id":"","url":"https://api.github.com/users/E3V3A","html_url":"https://github.com/E3V3A","followers_url":"https://api.github.com/users/E3V3A/followers","following_url":"https://api.github.com/users/E3V3A/following{/other_user}","gists_url":"https://api.github.com/users/E3V3A/gists{/gist_id}","starred_url":"https://api.github.com/users/E3V3A/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/E3V3A/subscriptions","organizations_url":"https://api.github.com/users/E3V3A/orgs","repos_url":"https://api.github.com/users/E3V3A/repos","events_url":"https://api.github.com/users/E3V3A/events{/privacy}","received_events_url":"https://api.github.com/users/E3V3A/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/SecUpwN/Android-IMSI-Catcher-Detector/labels/BUG","name":"BUG","color":"fc2929"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":17,"created_at":"2015-07-14T20:26:37Z","updated_at":"2015-07-15T00:13:22Z","closed_at":"2015-07-15T00:13:22Z","body":"As I have [stated](https://github.com/SecUpwN/Android-IMSI-Catcher-Detector/blob/de3c3a437bea1f64913f234e23e5cd64068ea20d/app/src/main/java/com/SecUpwN/AIMSICD/adapters/AIMSICDDbAdapter.java#L114-L141) over and [again](https://github.com/SecUpwN/Android-IMSI-Catcher-Detector/blob/de3c3a437bea1f64913f234e23e5cd64068ea20d/app/src/main/java/com/SecUpwN/AIMSICD/adapters/AIMSICDDbAdapter.java#L323-L344), and even clearly in the same file, [this](https://github.com/SecUpwN/Android-IMSI-Catcher-Detector/blob/de3c3a437bea1f64913f234e23e5cd64068ea20d/app/src/main/java/com/SecUpwN/AIMSICD/adapters/AIMSICDDbAdapter.java#L375-L379) is exactly the wrong kind of queries we should use.\r\n\r\n```java\r\n        return mDb.query( DBTableColumnIds.DBI_BTS_TABLE_NAME,\r\n                new String[]{\"Mcc\", \"Mnc\", \"Lac\", \"CellID\", \"Lng\", \"Lat\", \"Signal\", \"Timestamp\",\r\n                        \"Accuracy\", \"Speed\", \"Direction\", \"NetworkType\"}, \"OCID_SUBMITTED <> 1\",//<-- where we getting these tables OCID_SUBMITTED DBi_bts?/DBi_measure?/DBe_import?\r\n                null, null, null, null\r\n        );\r\n```\r\n\r\n**** impossible to read! \r\n\r\nInstead use **rawQuery()** like this:\r\n```java\r\n        String query = String.format(\"SELECT * FROM %s WHERE %s = %d\",\r\n                DBTableColumnIds.DBI_BTS_TABLE_NAME,            //DBi_bts\r\n                DBTableColumnIds.DBI_BTS_CID,  cell.getCID());  //CID\r\n        Cursor bts_cursor = mDb.rawQuery(query,null);\r\n```\r\n\r\nOr even better, just write out the damn constants (table and column names) in clear text:\r\n\r\n```java \r\n        String query = String.format(\r\n                \"SELECT * FROM DBi_bts WHERE CID = %d\", \r\n                cell.getCID()\r\n        );\r\n        Cursor bts_cursor = mDb.rawQuery(query,null);\r\n```\r\n\r\nPlease change all queries and Cursors to this.\r\n\r\n<bountysource-plugin>\r\n---\r\nWant to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/24338936-using-wrong-type-of-sql-queries?utm_campaign=plugin&utm_content=tracker%2F565750&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F565750&utm_medium=issues&utm_source=github).\r\n</bountysource-plugin>"}}