daily pastebin goal
70%
SHARE
TWEET

Untitled

a guest Dec 18th, 2018 52 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.   public ArrayList<Monument> retrieveMonumentsOnRoute(int RouteID) {
  2.         ArrayList<Monument> monumentList = new ArrayList<>();
  3.             String query = "SELECT * FROM MONUMENT JOIN ROUTEMONUMENT ON id = ROUTEMONUMENT.MonumentID WHERE ROUTEMONUMENT.RouteID =" + RouteID + ";";
  4.         Log.d("QUERYMONUMENT", query);
  5.         Cursor cursor = this.getReadableDatabase().rawQuery(query, null);
  6.  
  7.         if(cursor != null) {
  8.             cursor.moveToFirst();
  9.  
  10.         } else {
  11.             throw new Error("CURSOR IS NULL");
  12.         }
  13.  
  14.         if(cursor.getCount() > 0 ) {
  15.             do {
  16.                 Monument monument = new Monument.Builder()
  17.                         .name(cursor.getString(cursor.getColumnIndex(DatabaseQuery.COL_MONUMENT_MONUMENTNAME)))
  18.                         .description(cursor.getString(cursor.getColumnIndex(DatabaseQuery.COL_MONUMENT_DESCRIPTION)))
  19.                         .creator(cursor.getString(cursor.getColumnIndex(DatabaseQuery.COL_MONUMENT_CREATOR)))
  20.                         .soundURL(cursor.getString(cursor.getColumnIndex(DatabaseQuery.COL_MONUMENT_SOUNDFILEURL)))
  21.                         .imageURL(cursor.getString(cursor.getColumnIndex(DatabaseQuery.COL_MONUMENT_IMAGEURL)))
  22.                         .latitude(cursor.getDouble(cursor.getColumnIndex(DatabaseQuery.COL_MONUMENT_LATITUDE)))
  23.                         .longitude(cursor.getDouble(cursor.getColumnIndex(DatabaseQuery.COL_MONUMENT_LONGITUDE)))
  24.                         .constructionYear(cursor.getInt(cursor.getColumnIndex(DatabaseQuery.COL_MONUMENT_CONSTRUCTIONYEAR)))
  25.                         .build();
  26.  
  27.                 if(cursor.getInt(cursor.getColumnIndex(DatabaseQuery.COL_MONUMENT_ISVISITED)) == 1) {
  28.                     monument.setVisited(true);
  29.                 } else
  30.                 {
  31.                     monument.setVisited(false);
  32.                 }
  33.                 monumentList.add(monument);
  34.             }while (cursor.moveToNext());
  35.  
  36.             return monumentList;
  37.         } else {
  38.             cursor.close();
  39.             throw new Error("ROUTE COULD NOT BE FOUND BECAUSE EITHER IT DOES NOT EXIST OR INVALID PARAMETERS!");
  40.         }
  41.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top