Parameterize SQL queries
Also eliminate most calls to SQLiteDatabase.rawQuery.
This commit is contained in:
parent
020cac971f
commit
d6f643cb4d
@ -417,8 +417,9 @@ public class DB {
|
|||||||
// key in sqlite - table must be recreated)
|
// key in sqlite - table must be recreated)
|
||||||
if (oldVersion < 20) {
|
if (oldVersion < 20) {
|
||||||
List<Repo> oldrepos = new ArrayList<Repo>();
|
List<Repo> oldrepos = new ArrayList<Repo>();
|
||||||
Cursor c = db.rawQuery("select address, inuse, pubkey from "
|
Cursor c = db.query(TABLE_REPO,
|
||||||
+ TABLE_REPO, null);
|
new String[] { "address", "inuse", "pubkey" },
|
||||||
|
null, null, null, null, null);
|
||||||
c.moveToFirst();
|
c.moveToFirst();
|
||||||
while (!c.isAfterLast()) {
|
while (!c.isAfterLast()) {
|
||||||
Repo repo = new Repo();
|
Repo repo = new Repo();
|
||||||
@ -525,8 +526,8 @@ public class DB {
|
|||||||
List<String> result = new ArrayList<String>();
|
List<String> result = new ArrayList<String>();
|
||||||
Cursor c = null;
|
Cursor c = null;
|
||||||
try {
|
try {
|
||||||
c = db.rawQuery("select distinct category from " + TABLE_APP
|
c = db.query(true, TABLE_APP, new String[] { "category" },
|
||||||
+ " order by category", null);
|
null, null, null, null, "category", null);
|
||||||
c.moveToFirst();
|
c.moveToFirst();
|
||||||
while (!c.isAfterLast()) {
|
while (!c.isAfterLast()) {
|
||||||
String s = c.getString(0);
|
String s = c.getString(0);
|
||||||
@ -1017,8 +1018,8 @@ public class DB {
|
|||||||
values.put("compatible", upapk.compatible ? 1 : 0);
|
values.put("compatible", upapk.compatible ? 1 : 0);
|
||||||
if (oldapk != null) {
|
if (oldapk != null) {
|
||||||
db.update(TABLE_APK, values,
|
db.update(TABLE_APK, values,
|
||||||
"id = ? and vercode = " + Integer.toString(oldapk.vercode),
|
"id = ? and vercode = ?",
|
||||||
new String[] { oldapk.id });
|
new String[] { oldapk.id, Integer.toString(oldapk.vercode) });
|
||||||
} else {
|
} else {
|
||||||
db.insert(TABLE_APK, null, values);
|
db.insert(TABLE_APK, null, values);
|
||||||
}
|
}
|
||||||
@ -1031,7 +1032,7 @@ public class DB {
|
|||||||
try {
|
try {
|
||||||
c = db.query(TABLE_REPO, new String[] { "address", "inuse",
|
c = db.query(TABLE_REPO, new String[] { "address", "inuse",
|
||||||
"priority", "pubkey", "lastetag" },
|
"priority", "pubkey", "lastetag" },
|
||||||
"id = " + Integer.toString(id), null, null, null, null);
|
"id = ?", new String[] { Integer.toString(id) }, null, null, null);
|
||||||
if (!c.moveToFirst())
|
if (!c.moveToFirst())
|
||||||
return null;
|
return null;
|
||||||
Repo repo = new Repo();
|
Repo repo = new Repo();
|
||||||
@ -1053,9 +1054,9 @@ public class DB {
|
|||||||
List<Repo> repos = new ArrayList<Repo>();
|
List<Repo> repos = new ArrayList<Repo>();
|
||||||
Cursor c = null;
|
Cursor c = null;
|
||||||
try {
|
try {
|
||||||
c = db.rawQuery(
|
c = db.query(TABLE_REPO, new String[] { "id", "address", "inuse",
|
||||||
"select id, address, inuse, priority, pubkey, lastetag from "
|
"priority", "pubkey", "lastetag" },
|
||||||
+ TABLE_REPO + " order by priority", null);
|
null, null, null, null, "priority");
|
||||||
c.moveToFirst();
|
c.moveToFirst();
|
||||||
while (!c.isAfterLast()) {
|
while (!c.isAfterLast()) {
|
||||||
Repo repo = new Repo();
|
Repo repo = new Repo();
|
||||||
@ -1120,8 +1121,9 @@ public class DB {
|
|||||||
// connected to it...
|
// connected to it...
|
||||||
Cursor c = null;
|
Cursor c = null;
|
||||||
try {
|
try {
|
||||||
c = db.rawQuery("select id from " + TABLE_REPO
|
c = db.query(TABLE_REPO, new String[] { "id" },
|
||||||
+ " where address = '" + address + "'", null);
|
"address = ?", new String[] { address },
|
||||||
|
null, null, null, null);
|
||||||
c.moveToFirst();
|
c.moveToFirst();
|
||||||
if (!c.isAfterLast()) {
|
if (!c.isAfterLast()) {
|
||||||
db.delete(TABLE_APK, "repo = ?",
|
db.delete(TABLE_APK, "repo = ?",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user