Skip to content

Commit 3d3f854

Browse files
committed
1. Modified executeSelectQuery for executing query with customization.
1 parent b480f8a commit 3d3f854

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

app/src/main/java/com/amit/anim/AnimUtil.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
* 2018 May 14 - Monday - 03:05 PM
1919
* This AnimUtil class will help with animation
2020
**/
21+
@SuppressWarnings("unused")
2122
public class AnimUtil
2223
{
2324
private static final String TAG = AnimUtil.class.getSimpleName();

app/src/main/java/com/amit/db/DBHelper.java

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,50 @@ public boolean executeDatabaseOperations(String tableName,
331331

332332
// region COMMENTS FOR executeQuery method
333333

334+
/**
335+
* 2018 Feb 01 - Thursday - 03:52 PM
336+
* Execute Select Query
337+
*
338+
* parameters for this method are
339+
*
340+
* @param query - query that you want to execute
341+
*
342+
* @return cursor with records from the table
343+
**/
344+
345+
// endregion COMMENTS FOR executeQuery method
346+
@SuppressWarnings("unused")
347+
public Cursor executeSelectQuery(String query)
348+
{
349+
try
350+
{
351+
// query execution
352+
Cursor cursor = db.getWritableDatabase().rawQuery(query, null);
353+
354+
// if cursor is not null then moving the position to first
355+
// and returning the cursor
356+
if (cursor != null)
357+
{
358+
cursor.moveToFirst();
359+
}
360+
else
361+
{
362+
Log.e(TAG, "executeSelectQuery: cursor was null. No data found.");
363+
return null;
364+
}
365+
366+
return cursor;
367+
}
368+
catch (Exception e)
369+
{
370+
Log.e(TAG, "executeSelectQuery: in database helper class:\n");
371+
e.printStackTrace();
372+
return null;
373+
}
374+
}
375+
376+
// region COMMENTS FOR executeQuery method
377+
334378
/**
335379
* 2018 Feb 01 - Thursday - 03:52 PM
336380
* Execute Select Query

0 commit comments

Comments
 (0)