File tree Expand file tree Collapse file tree 2 files changed +8
-11
lines changed
app/src/main/java/br/com/sql
simplesql/src/main/java/com/simplesql/simplesql/config Expand file tree Collapse file tree 2 files changed +8
-11
lines changed Original file line number Diff line number Diff line change @@ -19,12 +19,5 @@ protected void onCreate(Bundle savedInstanceState) {
1919 Pessoa pessoa = new Pessoa ();
2020 pessoa .setName ("paulo" );
2121 simpleSQL .insert (pessoa ).execute ();
22-
23-
24-
25- List <Pessoa > list = simpleSQL .selectTable (new Pessoa ())
26- .fields (new String []{"name" })
27- .execute ();
28-
2922 }
3023}
Original file line number Diff line number Diff line change @@ -83,7 +83,7 @@ public class Select {
8383 private String SQLString ;
8484 private Object typeObject ;
8585 private static final String KEY_FUNCTION_PARAMETER = "%column" ;
86-
86+ private String type ;
8787 /**
8888 * @param typeObject
8989 * @param type
@@ -111,8 +111,8 @@ public Select(Object typeObject, String type) {
111111 default :
112112 SQLString = "SELECT " ;
113113
114-
115114 }
115+ this .type = type ;
116116 }
117117
118118
@@ -244,7 +244,7 @@ public Select like() {
244244 return this ;
245245 }
246246
247- public List execute () {
247+ public Object execute () {
248248 SQLiteDatabase read = helperBD .getReadableDatabase ();
249249 if (functionParameter ) {
250250 if (fields [0 ] == null || fields [0 ].equals ("" ))
@@ -256,7 +256,11 @@ public List execute() {
256256 Field [] fields = typeObject .getClass ().getDeclaredFields ();
257257 HashMap <String , Object > hashMap = new HashMap <>();
258258 try {
259- Cursor cursor = read .rawQuery (SQLString , null );
259+ Cursor cursor = read .rawQuery (SQLString , null );
260+ if (type .equals ("COUNT" )){
261+ cursor .moveToFirst ();
262+ return cursor .getInt (0 );
263+ }
260264 while (cursor .moveToNext ()) {
261265 for (Field f : fields ) {
262266 Object object = checkItem (f , cursor );
You can’t perform that action at this time.
0 commit comments