Use SQL parameter binding for performance (statements can be cached)
This commit is contained in:
parent
bcd0b185dc
commit
234bdd16fb
@ -296,8 +296,9 @@ public class DB {
|
|||||||
app.marketVercode = c.getInt(c.getColumnIndex("marketVercode"));
|
app.marketVercode = c.getInt(c.getColumnIndex("marketVercode"));
|
||||||
app.hasUpdates = false;
|
app.hasUpdates = false;
|
||||||
|
|
||||||
c2 = db.rawQuery("select * from " + TABLE_APK + " where "
|
c2 = db.rawQuery("select * from " + TABLE_APK
|
||||||
+ "id = '" + app.id + "' order by vercode desc", null);
|
+ " where id = ? order by vercode desc",
|
||||||
|
new String[] { app.id });
|
||||||
c2.moveToFirst();
|
c2.moveToFirst();
|
||||||
while (!c2.isAfterLast()) {
|
while (!c2.isAfterLast()) {
|
||||||
Apk apk = new Apk();
|
Apk apk = new Apk();
|
||||||
@ -308,7 +309,8 @@ public class DB {
|
|||||||
apk.hash = c2.getString(c2.getColumnIndex("hash"));
|
apk.hash = c2.getString(c2.getColumnIndex("hash"));
|
||||||
apk.size = c2.getInt(c2.getColumnIndex("size"));
|
apk.size = c2.getInt(c2.getColumnIndex("size"));
|
||||||
apk.apkName = c2.getString(c2.getColumnIndex("apkName"));
|
apk.apkName = c2.getString(c2.getColumnIndex("apkName"));
|
||||||
apk.apkSource = c2.getString(c2.getColumnIndex("apkSource"));
|
apk.apkSource = c2
|
||||||
|
.getString(c2.getColumnIndex("apkSource"));
|
||||||
app.apks.add(apk);
|
app.apks.add(apk);
|
||||||
c2.moveToNext();
|
c2.moveToNext();
|
||||||
}
|
}
|
||||||
@ -405,8 +407,8 @@ public class DB {
|
|||||||
// in the repos.
|
// in the repos.
|
||||||
Log.d("FDroid", "AppUpdate: " + app.name
|
Log.d("FDroid", "AppUpdate: " + app.name
|
||||||
+ " is no longer in any repository - removing");
|
+ " is no longer in any repository - removing");
|
||||||
db.delete(TABLE_APP, "id = '" + app.id + "'", null);
|
db.delete(TABLE_APP, "id = ?", new String[] { app.id });
|
||||||
db.delete(TABLE_APK, "id = '" + app.id + "'", null);
|
db.delete(TABLE_APK, "id = ?", new String[] { app.id });
|
||||||
} else {
|
} else {
|
||||||
for (Apk apk : app.apks) {
|
for (Apk apk : app.apks) {
|
||||||
if (!apk.updated) {
|
if (!apk.updated) {
|
||||||
@ -415,8 +417,8 @@ public class DB {
|
|||||||
Log.d("FDroid", "AppUpdate: Package " + apk.id + "/"
|
Log.d("FDroid", "AppUpdate: Package " + apk.id + "/"
|
||||||
+ apk.version
|
+ apk.version
|
||||||
+ " is no longer in any repository - removing");
|
+ " is no longer in any repository - removing");
|
||||||
db.delete(TABLE_APK, "id = '" + app.id
|
db.delete(TABLE_APK, "id = ? and version = ?",
|
||||||
+ "' and version ='" + apk.version + "'", null);
|
new String[] { app.id, apk.version });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -509,7 +511,7 @@ public class DB {
|
|||||||
values.put("marketVercode", upapp.marketVercode);
|
values.put("marketVercode", upapp.marketVercode);
|
||||||
values.put("hasUpdates", upapp.hasUpdates ? 1 : 0);
|
values.put("hasUpdates", upapp.hasUpdates ? 1 : 0);
|
||||||
if (oldapp != null) {
|
if (oldapp != null) {
|
||||||
db.update(TABLE_APP, values, "id = '" + oldapp.id + "'", null);
|
db.update(TABLE_APP, values, "id = ?", new String[] { oldapp.id });
|
||||||
} else {
|
} else {
|
||||||
db.insert(TABLE_APP, null, values);
|
db.insert(TABLE_APP, null, values);
|
||||||
}
|
}
|
||||||
@ -532,8 +534,8 @@ public class DB {
|
|||||||
values.put("apkName", upapk.apkName);
|
values.put("apkName", upapk.apkName);
|
||||||
values.put("apkSource", upapk.apkSource);
|
values.put("apkSource", upapk.apkSource);
|
||||||
if (oldapk != null) {
|
if (oldapk != null) {
|
||||||
db.update(TABLE_APK, values, "id = '" + oldapk.id
|
db.update(TABLE_APK, values, "id = ? and version =?", new String[] {
|
||||||
+ "' and version = '" + oldapk.version + "'", null);
|
oldapk.id, oldapk.version });
|
||||||
} else {
|
} else {
|
||||||
db.insert(TABLE_APK, null, values);
|
db.insert(TABLE_APK, null, values);
|
||||||
}
|
}
|
||||||
@ -542,7 +544,7 @@ public class DB {
|
|||||||
public void setInstalledVersion(String id, String version) {
|
public void setInstalledVersion(String id, String version) {
|
||||||
ContentValues values = new ContentValues();
|
ContentValues values = new ContentValues();
|
||||||
values.put("installedVersion", version);
|
values.put("installedVersion", version);
|
||||||
db.update(TABLE_APP, values, "id = '" + id + "'", null);
|
db.update(TABLE_APP, values, "id = ?", new String[] { id });
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get a list of the configured repositories.
|
// Get a list of the configured repositories.
|
||||||
@ -572,7 +574,8 @@ public class DB {
|
|||||||
|
|
||||||
public void changeServerStatus(String address) {
|
public void changeServerStatus(String address) {
|
||||||
db.rawQuery("update " + TABLE_REPO
|
db.rawQuery("update " + TABLE_REPO
|
||||||
+ " set inuse=1-inuse where address='" + address + "'", null);
|
+ " set inuse=1-inuse where address= ?",
|
||||||
|
new String[] { address });
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addServer(String address, int priority) {
|
public void addServer(String address, int priority) {
|
||||||
@ -585,8 +588,7 @@ public class DB {
|
|||||||
|
|
||||||
public void removeServers(Vector<String> addresses) {
|
public void removeServers(Vector<String> addresses) {
|
||||||
for (String address : addresses) {
|
for (String address : addresses) {
|
||||||
db.delete(TABLE_REPO, "address = '" + address + "'", null);
|
db.delete(TABLE_REPO, "address = ?", new String[] { address });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user