|
|
@ -26,6 +26,7 @@ import android.util.Log; |
|
|
|
import com.arialyy.aria.core.AriaManager; |
|
|
|
import com.arialyy.aria.core.AriaManager; |
|
|
|
import com.arialyy.aria.util.CheckUtil; |
|
|
|
import com.arialyy.aria.util.CheckUtil; |
|
|
|
import com.arialyy.aria.util.CommonUtil; |
|
|
|
import com.arialyy.aria.util.CommonUtil; |
|
|
|
|
|
|
|
import java.io.IOException; |
|
|
|
import java.lang.reflect.Field; |
|
|
|
import java.lang.reflect.Field; |
|
|
|
import java.lang.reflect.Type; |
|
|
|
import java.lang.reflect.Type; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.ArrayList; |
|
|
@ -180,7 +181,7 @@ final class SqlHelper extends SQLiteOpenHelper { |
|
|
|
print(FIND_DATA, sql); |
|
|
|
print(FIND_DATA, sql); |
|
|
|
Cursor cursor = db.rawQuery(sql, null); |
|
|
|
Cursor cursor = db.rawQuery(sql, null); |
|
|
|
List<T> data = cursor.getCount() > 0 ? newInstanceEntity(db, clazz, cursor) : null; |
|
|
|
List<T> data = cursor.getCount() > 0 ? newInstanceEntity(db, clazz, cursor) : null; |
|
|
|
cursor.close(); |
|
|
|
closeCursor(cursor); |
|
|
|
close(db); |
|
|
|
close(db); |
|
|
|
return data; |
|
|
|
return data; |
|
|
|
} |
|
|
|
} |
|
|
@ -223,7 +224,7 @@ final class SqlHelper extends SQLiteOpenHelper { |
|
|
|
print(FIND_DATA, sb.toString()); |
|
|
|
print(FIND_DATA, sb.toString()); |
|
|
|
Cursor cursor = db.rawQuery(sb.toString(), null); |
|
|
|
Cursor cursor = db.rawQuery(sb.toString(), null); |
|
|
|
List<T> data = cursor.getCount() > 0 ? newInstanceEntity(db, clazz, cursor) : null; |
|
|
|
List<T> data = cursor.getCount() > 0 ? newInstanceEntity(db, clazz, cursor) : null; |
|
|
|
cursor.close(); |
|
|
|
closeCursor(cursor); |
|
|
|
close(db); |
|
|
|
close(db); |
|
|
|
return data; |
|
|
|
return data; |
|
|
|
} |
|
|
|
} |
|
|
@ -238,7 +239,7 @@ final class SqlHelper extends SQLiteOpenHelper { |
|
|
|
print(FIND_ALL_DATA, sb.toString()); |
|
|
|
print(FIND_ALL_DATA, sb.toString()); |
|
|
|
Cursor cursor = db.rawQuery(sb.toString(), null); |
|
|
|
Cursor cursor = db.rawQuery(sb.toString(), null); |
|
|
|
List<T> data = cursor.getCount() > 0 ? newInstanceEntity(db, clazz, cursor) : null; |
|
|
|
List<T> data = cursor.getCount() > 0 ? newInstanceEntity(db, clazz, cursor) : null; |
|
|
|
cursor.close(); |
|
|
|
closeCursor(cursor); |
|
|
|
close(db); |
|
|
|
close(db); |
|
|
|
return data; |
|
|
|
return data; |
|
|
|
} |
|
|
|
} |
|
|
@ -394,7 +395,7 @@ final class SqlHelper extends SQLiteOpenHelper { |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
|
e.printStackTrace(); |
|
|
|
} finally { |
|
|
|
} finally { |
|
|
|
if (cursor != null) cursor.close(); |
|
|
|
closeCursor(cursor); |
|
|
|
close(db); |
|
|
|
close(db); |
|
|
|
} |
|
|
|
} |
|
|
|
return false; |
|
|
|
return false; |
|
|
@ -564,7 +565,7 @@ final class SqlHelper extends SQLiteOpenHelper { |
|
|
|
entity.rowID = cursor.getInt(cursor.getColumnIndex("rowid")); |
|
|
|
entity.rowID = cursor.getInt(cursor.getColumnIndex("rowid")); |
|
|
|
entitys.add(entity); |
|
|
|
entitys.add(entity); |
|
|
|
} |
|
|
|
} |
|
|
|
cursor.close(); |
|
|
|
closeCursor(cursor); |
|
|
|
} catch (InstantiationException e) { |
|
|
|
} catch (InstantiationException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
e.printStackTrace(); |
|
|
|
} catch (IllegalAccessException e) { |
|
|
|
} catch (IllegalAccessException e) { |
|
|
@ -586,6 +587,16 @@ final class SqlHelper extends SQLiteOpenHelper { |
|
|
|
return findData(db, params[0], params[1] + "=?", primary); |
|
|
|
return findData(db, params[0], params[1] + "=?", primary); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static void closeCursor(Cursor cursor){ |
|
|
|
|
|
|
|
if (cursor != null && !cursor.isClosed()) { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
cursor.close(); |
|
|
|
|
|
|
|
} catch (android.database.SQLException e) { |
|
|
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static void close(SQLiteDatabase db) { |
|
|
|
private static void close(SQLiteDatabase db) { |
|
|
|
//if (db != null && db.isOpen()) db.close();
|
|
|
|
//if (db != null && db.isOpen()) db.close();
|
|
|
|
} |
|
|
|
} |
|
|
|