@@ -126,8 +126,10 @@ public Split getSplit(long id){
126126 Cursor cursor = fetchRecord (id );
127127
128128 Split split = null ;
129- if (cursor != null && cursor .moveToFirst ()){
130- split = buildSplitInstance (cursor );
129+ if (cursor != null ) {
130+ if (cursor .moveToFirst ()) {
131+ split = buildSplitInstance (cursor );
132+ }
131133 cursor .close ();
132134 }
133135 return split ;
@@ -248,10 +250,11 @@ public long getID(String uid){
248250 new String [] {SplitEntry ._ID },
249251 SplitEntry .COLUMN_UID + " = ?" , new String []{uid }, null , null , null );
250252 long result = -1 ;
251- if (cursor != null && cursor .moveToFirst ()){
252- Log .d (TAG , "Transaction already exists. Returning existing id" );
253- result = cursor .getLong (cursor .getColumnIndexOrThrow (SplitEntry ._ID ));
254-
253+ if (cursor != null ){
254+ if (cursor .moveToFirst ()) {
255+ Log .d (TAG , "Transaction already exists. Returning existing id" );
256+ result = cursor .getLong (cursor .getColumnIndexOrThrow (SplitEntry ._ID ));
257+ }
255258 cursor .close ();
256259 }
257260 return result ;
@@ -347,8 +350,11 @@ public String getTransactionUID(long transactionId){
347350 null , null , null , null );
348351
349352 String trxUID = null ;
350- if (cursor != null && cursor .moveToFirst ()){
351- trxUID = cursor .getString (cursor .getColumnIndexOrThrow (TransactionEntry .COLUMN_UID ));
353+ if (cursor != null ) {
354+ if (cursor .moveToFirst ()) {
355+ trxUID = cursor .getString (cursor .getColumnIndexOrThrow (TransactionEntry .COLUMN_UID ));
356+ }
357+ cursor .close ();
352358 }
353359
354360 return trxUID ;
0 commit comments