11
11
import org .telegram .messenger .FileLog ;
12
12
import org .telegram .ui .ApplicationLoader ;
13
13
14
- import java .util .HashMap ;
15
- import java .util .Map ;
16
-
17
14
public class SQLiteDatabase {
18
15
private final int sqliteHandle ;
19
16
20
- private final Map <String , SQLitePreparedStatement > preparedMap = new HashMap <String , SQLitePreparedStatement >();
21
17
private boolean isOpen = false ;
22
18
private boolean inTransaction = false ;
23
19
@@ -36,23 +32,13 @@ public boolean tableExists(String tableName) throws SQLiteException {
36
32
return executeInt (s , tableName ) != null ;
37
33
}
38
34
39
- public void execute (String sql , Object ... args ) throws SQLiteException {
40
- checkOpened ();
41
- SQLiteCursor cursor = query (sql , args );
42
- try {
43
- cursor .next ();
44
- } finally {
45
- cursor .dispose ();
46
- }
47
- }
48
-
49
35
public SQLitePreparedStatement executeFast (String sql ) throws SQLiteException {
50
36
return new SQLitePreparedStatement (this , sql , true );
51
37
}
52
38
53
39
public Integer executeInt (String sql , Object ... args ) throws SQLiteException {
54
40
checkOpened ();
55
- SQLiteCursor cursor = query (sql , args );
41
+ SQLiteCursor cursor = queryFinalized (sql , args );
56
42
try {
57
43
if (!cursor .next ()) {
58
44
return null ;
@@ -63,18 +49,6 @@ public Integer executeInt(String sql, Object... args) throws SQLiteException {
63
49
}
64
50
}
65
51
66
- public SQLiteCursor query (String sql , Object ... args ) throws SQLiteException {
67
- checkOpened ();
68
- SQLitePreparedStatement stmt = preparedMap .get (sql );
69
-
70
- if (stmt == null ) {
71
- stmt = new SQLitePreparedStatement (this , sql , false );
72
- preparedMap .put (sql , stmt );
73
- }
74
-
75
- return stmt .query (args );
76
- }
77
-
78
52
public SQLiteCursor queryFinalized (String sql , Object ... args ) throws SQLiteException {
79
53
checkOpened ();
80
54
return new SQLitePreparedStatement (this , sql , true ).query (args );
@@ -83,9 +57,6 @@ public SQLiteCursor queryFinalized(String sql, Object... args) throws SQLiteExce
83
57
public void close () {
84
58
if (isOpen ) {
85
59
try {
86
- for (SQLitePreparedStatement stmt : preparedMap .values ()) {
87
- stmt .finalizeQuery ();
88
- }
89
60
commitTransaction ();
90
61
closedb (sqliteHandle );
91
62
} catch (SQLiteException e ) {
0 commit comments