File tree Expand file tree Collapse file tree 1 file changed +14
-22
lines changed
app/src/main/java/com/github/mobile/persistence Expand file tree Collapse file tree 1 file changed +14
-22
lines changed Original file line number Diff line number Diff line change @@ -126,16 +126,12 @@ private <E> List<E> requestAndStore(final SQLiteOpenHelper helper,
126126 if (db == null )
127127 return items ;
128128
129+ db .beginTransaction ();
129130 try {
130- db .beginTransaction ();
131- try {
132- persistableResource .store (db , items );
133- db .setTransactionSuccessful ();
134- } finally {
135- db .endTransaction ();
136- }
131+ persistableResource .store (db , items );
132+ db .setTransactionSuccessful ();
137133 } finally {
138- db .close ();
134+ db .endTransaction ();
139135 }
140136 return items ;
141137 }
@@ -146,22 +142,18 @@ private <E> List<E> loadFromDB(final SQLiteOpenHelper helper,
146142 if (db == null )
147143 return null ;
148144
145+ Cursor cursor = persistableResource .getCursor (db );
149146 try {
150- Cursor cursor = persistableResource .getCursor (db );
151- try {
152- if (!cursor .moveToFirst ())
153- return null ;
154-
155- List <E > cached = new ArrayList <E >();
156- do {
157- cached .add (persistableResource .loadFrom (cursor ));
158- } while (cursor .moveToNext ());
159- return cached ;
160- } finally {
161- cursor .close ();
162- }
147+ if (!cursor .moveToFirst ())
148+ return null ;
149+
150+ List <E > cached = new ArrayList <E >();
151+ do {
152+ cached .add (persistableResource .loadFrom (cursor ));
153+ } while (cursor .moveToNext ());
154+ return cached ;
163155 } finally {
164- db .close ();
156+ cursor .close ();
165157 }
166158 }
167159
You can’t perform that action at this time.
0 commit comments