Example #1
0
  private boolean moveToNextWayPoint(Cursor trackCursor) {
    if (trackCursor.isLast()) {
      return false;
    }

    GeoPoint lastPoint = extractGeoPoint(trackCursor);
    boolean onScreen = isOnScreen(lastPoint);

    GeoPoint evalPoint;
    if (onScreen) {
      while (trackCursor.moveToNext()) {
        step++;
        if (trackCursor.isLast()) {
          //               Log.d(TAG, "last on screen "+trackCursor.getPosition() );
          return true;
        }

        evalPoint = extractGeoPoint(trackCursor);
        if (!isOnScreen(evalPoint)) {
          //               Log.d(TAG, "first out screen "+trackCursor.getPosition() );
          return true;
        }
        if (isGoodDrawable()) {
          return true;
        }
      }
      trackCursor.moveToLast();
      return false;
    } else {
      while (trackCursor.moveToNext()) {
        step++;
        if (trackCursor.isLast()) {
          //               Log.d(TAG, "last off screen "+trackCursor.getPosition() );
          return true;
        }

        evalPoint = extractGeoPoint(trackCursor);
        if (isOnScreen(evalPoint)) {
          moveToGeoPoint(lastPoint);
          //               Log.d(TAG, "first in screen "+trackCursor.getPosition() );
          return true;
        }
        lastPoint = evalPoint;
      }
      trackCursor.moveToLast();
      return false;
    }
  }
Example #2
0
  public static void displayTopScores(Canvas canvas, Paint p, Cursor c, int x, int y, Align a) {

    x -= HUD_TOP_SCORES_TEXT_OFFSET;
    y += MARGIN_TOP + HUD_TOP_SCORES_Y_START;
    String name;
    int score;
    int colScore = c.getColumnIndex(ScoreManager.DATABASE_TABLE_SCORES_SCORE);
    int colName = c.getColumnIndex(ScoreManager.DATABASE_TABLE_SCORES_NAME);

    c.moveToLast();
    p.setTextAlign(a);
    // paint title
    p.setColor(HUD_TOP_SCORES_TITLE_COLOR);
    canvas.drawText("TopScore", x, y, p);
    y += 20;

    for (int i = 0;
        i < c.getCount() && i < ScoreManager.TOP_SCORE_NB;
        i++, c.moveToPrevious(), y += 14) {

      score = c.getInt(colScore);
      name = c.getString(colName);
      p.setColor(HUD_TOP_SCORES_RANK_COLOR);
      canvas.drawText((i + 1) + ". " + name + ": " + score, x, y, p);
    }
    c.close();
  }
Example #3
0
  /** 批量向歌单添加音乐 */
  public static void addSongListToPlaylist(
      final Context context, final PlayList playlist, final ArrayList<Song> songs) {
    Cursor cur =
        context
            .getContentResolver()
            .query(
                MediaStore.Audio.Playlists.Members.getContentUri(
                    "external", playlist.getmPlayListId()),
                null,
                null,
                null,
                MediaStore.Audio.Playlists.Members.TRACK + " ASC");

    long count = 0;
    if (cur.moveToLast()) {
      count = cur.getLong(cur.getColumnIndex(MediaStore.Audio.Playlists.Members.TRACK));
    }
    cur.close();

    ContentValues[] values = new ContentValues[songs.size()];
    for (int i = 0; i < songs.size(); i++) {
      values[i] = new ContentValues();
      values[i].put(MediaStore.Audio.Playlists.Members.PLAY_ORDER, count + 1);
      values[i].put(MediaStore.Audio.Playlists.Members.AUDIO_ID, songs.get(i).getmSongId());
    }

    Uri uri =
        MediaStore.Audio.Playlists.Members.getContentUri("external", playlist.getmPlayListId());
    ContentResolver resolver = context.getContentResolver();
    resolver.bulkInsert(uri, values);
    resolver.notifyChange(Uri.parse("content://media"), null);
  }
Example #4
0
  public static Photo getPhoto(ContentResolver c, long rawContactId) {
    Photo photo = new Photo();
    String where =
        ContactsContract.Data.RAW_CONTACT_ID
            + " = '"
            + rawContactId
            + "' AND "
            + ContactsContract.Data.MIMETYPE
            + " = '"
            + ContactsContract.CommonDataKinds.Photo.CONTENT_ITEM_TYPE
            + "'";

    Cursor c1 =
        c.query(
            ContactsContract.Data.CONTENT_URI,
            new String[] {
              ContactsContract.CommonDataKinds.Photo.PHOTO,
              ContactsContract.Data.SYNC2,
              ContactsContract.Data.SYNC3
            },
            where,
            null,
            null);
    if (c1.getCount() > 0) {
      c1.moveToLast();
      photo.data = c1.getBlob(c1.getColumnIndex(ContactsContract.CommonDataKinds.Photo.PHOTO));
      photo.timestamp = Long.valueOf(c1.getString(c1.getColumnIndex(ContactsContract.Data.SYNC2)));
      photo.url = c1.getString(c1.getColumnIndex(ContactsContract.Data.SYNC3));
    }
    c1.close();
    return photo;
  }
  @Override
  protected void onHandleIntent(Intent intent) {
    Bundle b = intent.getExtras();
    latitude = b.getDouble("latitude");
    longitude = b.getDouble("longitude");
    timeStamp = b.getString("timeStamp");
    deviceId = b.getString("deviceId");

    Cursor cursor =
        getContentResolver()
            .query(LocationContract.UserLocationDetails.CONTENT_URI, null, null, null, null);
    if (!(cursor.moveToFirst()) || (cursor.getCount() == 0)) {
      insertLocationDetailsIntoDb();
      sendLocationDetailsToServer();
      cursor.close();
    } else {
      cursor.moveToLast();
      double previousLat = cursor.getDouble(cursor.getColumnIndex("latitude"));
      double previousLong = cursor.getDouble(cursor.getColumnIndex("longitude"));
      Float distance = distFrom(previousLat, previousLong, latitude, longitude);
      if (distance > 100) {
        insertLocationDetailsIntoDb();
        sendLocationDetailsToServer();
      } else {
        // No uploading required since distance between previous uploaded location and current
        // location is less than 100m
      }
      cursor.close();
    }
  }
Example #6
0
  private void init() {

    dbHelper = new DBHelper(SettingsActivity.this, "Data.db", null, 1);
    database = dbHelper.getWritableDatabase();
    stepDBHelper = new StepDBHelper(SettingsActivity.this, "stepNum.db", null, 1);
    database2 = stepDBHelper.getWritableDatabase();
    getUserIntent = getIntent();
    backIntent = new Intent(SettingsActivity.this, StepCounterActivity.class);
    backIntent.putExtra("UserName", str_UserName);
    loginIntent = new Intent(SettingsActivity.this, LoginActivity.class);
    str_UserName = getUserIntent.getStringExtra("UserName");
    Cursor cursor = database.rawQuery(str_selectUser, new String[] {str_UserName});
    cursor.moveToLast();
    step_length = Integer.parseInt(cursor.getString(3));
    weight = Integer.parseInt(cursor.getString(4));
    /** 布局控件 */
    tv_step_length_vlaue = (TextView) this.findViewById(R.id.step_lenth_value);
    tv_weight_value = (TextView) this.findViewById(R.id.weight_value);
    sb_step_length = (SeekBar) this.findViewById(R.id.step_lenth);
    sb_weight = (SeekBar) this.findViewById(R.id.weight);
    et_password = (EditText) findViewById(R.id.password_edit);
    sb_step_length.setProgress((step_length - 30) / 5); // 步长按钮在进度条上占得比例
    sb_weight.setProgress(weight - 20);
    tv_step_length_vlaue.setText(step_length + getString(R.string.cm));
    tv_weight_value.setText(weight + getString(R.string.kg));
  }
 /**
  * Previous path GeoPoint was off screen and the next one will be to or the first on screen when
  * the path reaches the projection.
  *
  * @return
  */
 private boolean moveOffscreenWaypoint(int flexStepsize) {
   while (mWaypointsCursor.move(flexStepsize)) {
     if (mWaypointsCursor.isLast()) {
       return true;
     }
     GeoPoint evalPoint = extractGeoPoint();
     // Do no include log wrong 0.0 lat 0.0 long, skip to next value in while-loop
     if (evalPoint.getLatitudeE6() == 0 || evalPoint.getLongitudeE6() == 0) {
       continue;
     }
     //         Log.d( TAG, String.format( "Evaluate point number %d ",
     // mWaypointsCursor.getPosition() ) );
     if (possibleScreenPass(mPrevGeoPoint, evalPoint)) {
       mPrevGeoPoint = evalPoint;
       if (flexStepsize == 1) // Just stumbled over a border
       {
         return true;
       } else {
         mWaypointsCursor.move(-1 * flexStepsize); // Take 1 step back
         return moveOffscreenWaypoint(flexStepsize / 2); // Continue at halve accelerated speed
       }
     } else {
       moveToGeoPoint(evalPoint);
       mPrevGeoPoint = evalPoint;
     }
   }
   return mWaypointsCursor.moveToLast();
 }
Example #8
0
  public static synchronized void saveInterruption(Context context, String type) {
    SharedPreferences preferences = context.getSharedPreferences("TRIP", 1);
    boolean isTripStarted = preferences.getBoolean("isTripStarted", false);
    if (isTripStarted) {
      TempTripJourneyWayPointsRepository repos = new TempTripJourneyWayPointsRepository(context);
      Cursor cursor = repos.getTrip();
      Log.d(TAG, "Trip count " + cursor.getCount());
      if (cursor != null && cursor.getCount() > 0) {
        cursor.moveToLast();
        SCInterruption scInterruption = new SCInterruption();
        scInterruption.setStarted_at(DateUtils.getTimeStamp(new Date().getTime()));
        scInterruption.setLatitude(Double.toString(cursor.getDouble(2)));
        scInterruption.setLongitude(Double.toString(cursor.getDouble(3)));
        scInterruption.setEstimatedSpeed(
            Double.toString(repos.getAvarageEstimatedSpeedForAutoTripStart()));
        scInterruption.setSchooleZoneActive(false);
        scInterruption.setPhoneRuleActive(false);
        scInterruption.setSmsRuleActive(false);
        scInterruption.setType(type);
        InteruptionRepository interuptionRepository = new InteruptionRepository(context);
        interuptionRepository.insertInterupt(scInterruption);
        // Toast.makeText(context, "Interruption Captured : Type = " +
        // type, Toast.LENGTH_LONG)
        // .show();

      }
    }
  }
Example #9
0
  /** 向歌单添加音乐 */
  public static void addSongToPlaylist(
      final Context context, final PlayList playlist, final Song song) {
    Cursor cur =
        context
            .getContentResolver()
            .query(
                MediaStore.Audio.Playlists.Members.getContentUri(
                    "external", playlist.getmPlayListId()),
                null,
                null,
                null,
                MediaStore.Audio.Playlists.Members.TRACK + " ASC");

    long count = 0;
    if (cur.moveToLast()) {
      count = cur.getLong(cur.getColumnIndex(MediaStore.Audio.Playlists.Members.TRACK));
    }
    cur.close();

    ContentValues values = new ContentValues();
    values.put(MediaStore.Audio.Playlists.Members.PLAY_ORDER, count + 1);
    values.put(MediaStore.Audio.Playlists.Members.AUDIO_ID, song.getmSongId());

    Uri uri =
        MediaStore.Audio.Playlists.Members.getContentUri("external", playlist.getmPlayListId());
    ContentResolver resolver = context.getContentResolver();
    resolver.insert(uri, values);
    resolver.notifyChange(Uri.parse("content://media"), null);
  }
  private static final MmsSmsDeliveryInfo getSmsNewDeliveryInfo(Context context) {
    ContentResolver resolver = context.getContentResolver();
    Cursor cursor =
        SqliteWrapper.query(
            context,
            resolver,
            Sms.CONTENT_URI,
            SMS_STATUS_PROJECTION,
            NEW_DELIVERY_SM_CONSTRAINT,
            null,
            Sms.DATE);

    if (cursor == null) return null;

    try {
      if (!cursor.moveToLast()) return null;

      String address = cursor.getString(COLUMN_SMS_ADDRESS);
      long timeMillis = 3000;

      return new MmsSmsDeliveryInfo(
          String.format(context.getString(R.string.delivery_toast_body), address), timeMillis);

    } finally {
      cursor.close();
    }
  }
Example #11
0
 public static List<Contact> getActiveContacts() {
   List<Contact> list = new ArrayList<>();
   Cursor cursor = null;
   try {
     cursor =
         SawimApplication.getDatabaseHelper()
             .getReadableDatabase()
             .query(
                 DatabaseHelper.TABLE_CHAT_HISTORY,
                 null,
                 null,
                 null,
                 DatabaseHelper.CONTACT_ID,
                 null,
                 null,
                 null);
     if (cursor.moveToLast()) {
       do {
         String protocolId = cursor.getString(cursor.getColumnIndex(DatabaseHelper.ACCOUNT_ID));
         String uniqueUserId = cursor.getString(cursor.getColumnIndex(DatabaseHelper.CONTACT_ID));
         Protocol protocol = RosterHelper.getInstance().getProtocol(protocolId);
         if (protocol != null) {
           list.add(protocol.getItemByUID(uniqueUserId));
         }
       } while (cursor.moveToPrevious());
     }
   } finally {
     if (cursor != null) {
       cursor.close();
     }
   }
   return list;
 }
 public int getLastuseridFromGyro() {
   SQLiteDatabase db = this.getWritableDatabase();
   Cursor cursor = db.rawQuery("select count(*) from gyro", null);
   cursor.moveToLast();
   int tempCL = cursor.getColumnIndex("userid");
   int result = cursor.getInt(tempCL);
   return result;
 }
 public double getLastacc_yFromAccelerator() {
   SQLiteDatabase db = this.getWritableDatabase();
   Cursor cursor = db.rawQuery("select count(*) from accelerator", null);
   cursor.moveToLast();
   int tempCL = cursor.getColumnIndex("acc_y");
   double result = cursor.getDouble(tempCL);
   return result;
 }
 public int getLasheartrateFromHeartrate() {
   SQLiteDatabase db = this.getWritableDatabase();
   Cursor cursor = db.rawQuery("select count(*) from heartrate", null);
   cursor.moveToLast();
   int tempCL = cursor.getColumnIndex("heartrate");
   int result = cursor.getInt(tempCL);
   return result;
 }
 public double getLastforce6FromForce() {
   SQLiteDatabase db = this.getWritableDatabase();
   Cursor cursor = db.rawQuery("select count(*) from force", null);
   cursor.moveToLast();
   int tempCL = cursor.getColumnIndex("force6");
   double result = cursor.getDouble(tempCL);
   return result;
 }
 public double getLasttempvalueFromTemperature() {
   SQLiteDatabase db = this.getWritableDatabase();
   Cursor cursor = db.rawQuery("select count(*) from temperature", null);
   cursor.moveToLast();
   int tempCL = cursor.getColumnIndex("tempvalue");
   double result = cursor.getDouble(tempCL);
   return result;
 }
 public double getLastangle_acc_zFromGyro() {
   SQLiteDatabase db = this.getWritableDatabase();
   Cursor cursor = db.rawQuery("select count(*) from gyro", null);
   cursor.moveToLast();
   int tempCL = cursor.getColumnIndex("angle_acc_z");
   double result = cursor.getDouble(tempCL);
   return result;
 }
 /**
  * Gets a last byte array saved in this database.
  *
  * @return the last entry in this database; null if none was found
  */
 public byte[] getLastEntry() {
   try (SQLiteDatabase db = this.getReadableDatabase();
       Cursor res = db.rawQuery("SELECT * FROM " + Constants.DATABASE_TABLE, null)) {
     // get last entry
     if (res.moveToLast()) {
       return res.getBlob(res.getColumnIndex(Constants.DATABASE_COLUMN));
     }
   }
   return null;
 }
Example #19
0
 public static int count() {
   SQLiteDatabase db = DALHelper.getInstance().getReadableDatabase();
   Cursor cursor = db.rawQuery("select count(*) from " + TABLE_NAME, null);
   int count = 0;
   if (cursor.moveToLast()) {
     count = cursor.getInt(0);
   }
   db.close();
   return count;
 }
Example #20
0
  public void insertDayMaxSteps(int y, int m, int d, int s, float dis, float cal, long st) {

    Cursor c = queryDayAll(y, m, d);
    if (c != null) {
      c.moveToLast();
    } else {
      return;
    }

    int lap, year, month, day, hour, minute, lapsteps, steps, pace, achievement;
    float lapdistance, distance, lapcalories, calories, speed;
    long lapsteptime, steptime;

    year = y;
    month = m;
    day = d;
    hour = 23;
    minute = 0;
    lap = 0;
    lapsteps = 0;
    lapdistance = 0;
    lapcalories = 0;
    lapsteptime = 0;
    steps = s;
    distance = dis;
    calories = cal;
    speed = 0;
    pace = 0;
    steptime = st;
    achievement = 0;

    ContentValues newTaskValue = new ContentValues();
    try {
      newTaskValue.put(Constants.KEY_LAP, lap);
      newTaskValue.put(Constants.KEY_YEAR, year);
      newTaskValue.put(Constants.KEY_MONTH, month); // month[0-11]
      newTaskValue.put(Constants.KEY_DAY, day);
      newTaskValue.put(Constants.KEY_HOUR, hour);
      newTaskValue.put(Constants.KEY_MINUTE, minute);
      newTaskValue.put(Constants.KEY_LAPSTEPS, lapsteps);
      newTaskValue.put(Constants.KEY_LAPDISTANCE, lapdistance);
      newTaskValue.put(Constants.KEY_LAPCALORIES, lapcalories);
      newTaskValue.put(Constants.KEY_LAPSTEPTIME, lapsteptime);
      newTaskValue.put(Constants.KEY_STEPS, steps);
      newTaskValue.put(Constants.KEY_DISTANCE, distance);
      newTaskValue.put(Constants.KEY_CALORIES, calories);
      newTaskValue.put(Constants.KEY_SPEED, speed);
      newTaskValue.put(Constants.KEY_PACE, pace);
      newTaskValue.put(Constants.KEY_STEPTIME, steptime);
      newTaskValue.put(Constants.KEY_ACHIEVEMENT, achievement);
      mDB.insert(Constants.TABLE_NAME, null, newTaskValue);
    } catch (SQLiteException ex) {
      ex.printStackTrace();
    }
  }
Example #21
0
  public void sendList(View view) {

    message = editText.getText().toString();
    if (message.length() > 0) {

      SQLiteDatabase db = NB.getReadableDatabase();

      // String command = "select distict title from Notes";

      Cursor C = db.query("TextTable", new String[] {"id", "text"}, null, null, null, null, null);

      C.moveToLast();
      int nextpos;

      if (C.getCount() < 1) {
        nextpos = 1;
      } else {
        nextpos = C.getInt(0);
        nextpos++;
      }

      SQLiteDatabase dataB = NB.getWritableDatabase();

      ContentValues vals = new ContentValues();
      vals.put("id", nextpos);
      vals.put("title", Title);
      vals.put("text", message);
      // isnew = true;
      if (isnew) {
        dataB.insert("TextTable", null, vals);
      } else {
        Toast.makeText(getApplicationContext(), "Updated", Toast.LENGTH_SHORT).show();
        dataB.update("TextTable", vals, "title=? AND text=?", new String[] {Title, Text});
      }

      dataB.close();

    } else {
      Toast.makeText(getApplicationContext(), "Nothing Entered", Toast.LENGTH_SHORT).show();
    }

    editText.setText("");

    NotesContentPage.NCP.finish();

    try {
      Class ourClass = Class.forName("com.example.notetest." + "NotesContentPage");
      Intent intent1 = new Intent(NewNote.this, ourClass);
      intent1.putExtra("NoteSelected", Title);
      startActivity(intent1);
    } catch (ClassNotFoundException e) {
      e.printStackTrace();
    }
  }
  @Override
  public T getCurrent() {
    assertEmptyCursor();

    if (originalCursor.isBeforeFirst()) {
      originalCursor.moveToFirst();
    }
    if (originalCursor.isAfterLast()) {
      originalCursor.moveToLast();
    }
    return construct();
  }
  /**
   * compare the player with the last player
   *
   * @param table
   * @param playerTime
   * @return true if current player's game time is better than the last
   */
  public boolean shouldBeInserted(String table, String playerTime) {
    int rowsCount = count(table);
    // if there are less records than the max records
    if (rowsCount < recordsToSave) return true;

    SQLiteDatabase readableDB = dbManager.getReadableDatabase();
    Cursor cursor = gerAllTableByRoundTime(readableDB, table);
    cursor.moveToLast();
    String lastPlayerTime = cursor.getString(cursor.getColumnIndex(COL_GAME_ROUND_TIME));
    // check if the new time is better than the last
    // if it is so the player's record should be updated within the table
    return playerTime.compareTo(lastPlayerTime) < 0;
  }
Example #24
0
  public float getSum() {
    float sum = 0;
    SQLiteDatabase db = getWritableDatabase();
    String query = "SELECT SUM(" + COL_3 + ") FROM " + PURCHASE_TABLE;
    Cursor cursor = db.rawQuery(query, null);
    if (cursor != null && cursor.getCount() > 0) {
      cursor.moveToLast();

      sum = cursor.getFloat(0);
      Log.e("Alan's tag", Float.toString(sum));
    }
    return sum;
  }
  @Override
  public Uri insert(Uri uri, ContentValues values) {
    DBHandler dbH = new DBHandler(getContext());
    SQLiteDatabase sdb = dbH.getWritableDatabase();
    sdb.insert(db.TABLE_KONTAKTER, null, values);

    Cursor c = sdb.query(db.TABLE_KONTAKTER, null, null, null, null, null, null);
    c.moveToLast();
    long minid = c.getLong(0);
    getContext().getContentResolver().notifyChange(uri, null);

    return ContentUris.withAppendedId(uri, minid);
  }
Example #26
0
  public float getAverage() {
    float avg = 0;
    SQLiteDatabase db = getWritableDatabase();
    String query = "SELECT AVG(" + COL_3 + ") FROM " + PURCHASE_TABLE;
    Cursor cursor = db.rawQuery(query, null);
    if (cursor != null && cursor.getCount() > 0) {
      cursor.moveToLast();

      avg = cursor.getFloat(0);
      Log.e("Alan's tag", Float.toString(avg));
    }
    return avg;
  }
 /* Returns the latest evaluation for a patient, with all its properties */
 public Evaluation getFullLatestEvaluation(String patientUUID) {
   SQLiteDatabase db = this.getReadableDatabase();
   Cursor cursor =
       db.query(
           TABLE_EVALUATIONS,
           new String[] {
             KEY_EVALUATION_UUID,
             KEY_EVALUATION_ULCERAS,
             KEY_EVALUATION_AGRUPADAS,
             KEY_EVALUATION_LESIONES_H,
             KEY_EVALUATION_LESIONES_B,
             KEY_EVALUATION_LESIONES_LA,
             KEY_EVALUATION_LESIONES_RA,
             KEY_EVALUATION_LESIONES_LL,
             KEY_EVALUATION_LESIONES_RL,
             KEY_EVALUATION_ACTIVIDADES,
             KEY_EVALUATION_ANTECEDENTES,
             KEY_EVALUATION_MANTA,
             KEY_EVALUATION_DATE,
             KEY_EVALUATION_THRESHOLD,
             KEY_EVALUATION_SCORE
           },
           FK_PATIENT + "=?",
           new String[] {patientUUID},
           null,
           null,
           null,
           null);
   Evaluation evaluation = null;
   if (cursor != null && cursor.moveToLast()) {
     evaluation =
         new Evaluation(
             cursor.getString(0),
             cursor.getInt(1) == 1 ? true : false,
             cursor.getInt(2) == 1 ? true : false,
             cursor.getInt(3) == 1 ? true : false,
             cursor.getInt(4) == 1 ? true : false,
             cursor.getInt(5) == 1 ? true : false,
             cursor.getInt(6) == 1 ? true : false,
             cursor.getInt(7) == 1 ? true : false,
             cursor.getInt(8) == 1 ? true : false,
             cursor.getInt(9) == 1 ? true : false,
             cursor.getInt(10) == 1 ? true : false,
             cursor.getInt(11) == 1 ? true : false,
             cursor.getString(12),
             cursor.getInt(13),
             cursor.getInt(14));
   }
   db.close();
   return evaluation;
 }
Example #28
0
  public Cursor queryLapStepsForDay(int year, int month, int day, int lap) throws SQLException {

    try {
      String where =
          "SELECT "
              + Constants.KEY_ID
              + ", "
              + Constants.KEY_HOUR
              + ", "
              + Constants.KEY_MINUTE
              + ", "
              + Constants.KEY_LAPSTEPS
              + ", "
              + Constants.KEY_LAPDISTANCE
              + ", "
              + Constants.KEY_LAPCALORIES
              + ", "
              + Constants.KEY_LAPSTEPTIME
              + " FROM "
              + Constants.TABLE_NAME
              + " WHERE "
              + Constants.KEY_YEAR
              + " = ?"
              + " AND "
              + Constants.KEY_MONTH
              + " = ?"
              + " AND "
              + Constants.KEY_DAY
              + " = ?"
              + " AND "
              + Constants.KEY_LAP
              + " = ?"; // + " AND " + Constants.KEY_INDICATOR + " = ?"; //V131

      String[] whereArgs = {
        ((Integer) year).toString(),
        ((Integer) month).toString(),
        ((Integer) day).toString(),
        ((Integer) lap).toString()
      }; // , "1" };  //V131

      Cursor c = mDB.rawQuery(where, whereArgs);

      if (c != null) {
        c.moveToLast(); // V131  c.moveToFirst()
      }
      return c;
    } catch (SQLiteException ex) {
      // Log.i(TAG, ex.getMessage());
      return null;
    }
  }
Example #29
0
  /**
   * Used to find out if we are in a situation where the Camera Intent adds to images to the content
   * store.
   */
  private void checkForDuplicateImage() {
    Uri contentStore = whichContentStore();
    Cursor cursor = queryImgDB(contentStore);
    int currentNumOfImages = cursor.getCount();

    // delete the duplicate file if the difference is 2
    if ((currentNumOfImages - numPics) == 2) {
      cursor.moveToLast();
      int id =
          Integer.valueOf(cursor.getString(cursor.getColumnIndex(MediaStore.Images.Media._ID))) - 1;
      Uri uri = Uri.parse(contentStore + "/" + id);
      getContext().getContentResolver().delete(uri, null, null);
    }
  }
 /** Get lastest id */
 public int getLastId() {
   int id = -1;
   try {
     Cursor cursor =
         database.query(SQLiteDB.TABLE_SETTING, allColumns, null, null, null, null, null);
     cursor.moveToLast();
     Setting s = cursorToSetting(cursor);
     id = s.getId();
     cursor.close();
   } catch (Exception ex) {
     ex.printStackTrace();
   }
   return id;
 }