Example #1
0
 @Override
 public Uri save() {
   ContentValues initialValues = new ContentValues();
   initialValues.put(KEY_LABEL, label);
   initialValues.put(KEY_LABEL_NORMALIZED, Utils.normalize(label));
   Uri uri;
   if (getId() == 0) {
     if (!isMain(parentId)) {
       uri = null;
       AcraHelper.report(new Exception("Attempt to store deep category hierarchy detected"));
     } else {
       initialValues.put(KEY_PARENTID, parentId);
       try {
         uri = cr().insert(CONTENT_URI, initialValues);
       } catch (SQLiteConstraintException e) {
         uri = null;
       }
     }
   } else {
     uri = CONTENT_URI.buildUpon().appendPath(String.valueOf(getId())).build();
     try {
       cr().update(
               CONTENT_URI.buildUpon().appendPath(String.valueOf(getId())).build(),
               initialValues,
               null,
               null);
     } catch (SQLiteConstraintException e) {
       uri = null;
     }
   }
   return uri;
 }
  private void loadData(Bundle savedInstanceState, Uri appUri) {
    mAppSettings = new ApiDataAccessObject(this).getApiAppSettings(appUri);

    // get application name and icon from package manager
    String appName;
    Drawable appIcon = null;
    PackageManager pm = getApplicationContext().getPackageManager();
    try {
      ApplicationInfo ai = pm.getApplicationInfo(mAppSettings.getPackageName(), 0);

      appName = (String) pm.getApplicationLabel(ai);
      appIcon = pm.getApplicationIcon(ai);
    } catch (PackageManager.NameNotFoundException e) {
      // fallback
      appName = mAppSettings.getPackageName();
    }
    mAppNameView.setText(appName);
    mAppIconView.setImageDrawable(appIcon);

    Uri accountsUri = appUri.buildUpon().appendPath(KeychainContract.PATH_ACCOUNTS).build();
    Log.d(Constants.TAG, "accountsUri: " + accountsUri);
    Uri allowedKeysUri = appUri.buildUpon().appendPath(KeychainContract.PATH_ALLOWED_KEYS).build();
    Log.d(Constants.TAG, "allowedKeysUri: " + allowedKeysUri);
    startListFragments(savedInstanceState, accountsUri, allowedKeysUri);
  }
  public LocalBrowserDB(String profile) {
    mProfile = profile;
    mFolderIdMap = new HashMap<String, Long>();
    mDesktopBookmarksExist = null;
    mReadingListItemsExist = null;

    mBookmarksUriWithProfile = appendProfile(Bookmarks.CONTENT_URI);
    mParentsUriWithProfile = appendProfile(Bookmarks.PARENTS_CONTENT_URI);
    mHistoryUriWithProfile = appendProfile(History.CONTENT_URI);
    mImagesUriWithProfile = appendProfile(Images.CONTENT_URI);
    mCombinedUriWithProfile = appendProfile(Combined.CONTENT_URI);

    mDeletedHistoryUriWithProfile =
        mHistoryUriWithProfile
            .buildUpon()
            .appendQueryParameter(BrowserContract.PARAM_SHOW_DELETED, "1")
            .build();

    mUpdateHistoryUriWithProfile =
        mHistoryUriWithProfile
            .buildUpon()
            .appendQueryParameter(BrowserContract.PARAM_INCREMENT_VISITS, "true")
            .appendQueryParameter(BrowserContract.PARAM_INSERT_IF_NEEDED, "true")
            .build();
  }
  public static final class BookEntry implements BaseColumns {
    public static final Uri CONTENT_URI =
        BASE_CONTENT_URI.buildUpon().appendPath(PATH_BOOKS).build();

    public static final Uri FULL_CONTENT_URI =
        BASE_CONTENT_URI.buildUpon().appendPath(PATH_FULLBOOK).build();

    public static final String CONTENT_TYPE =
        "vnd.android.cursor.dir/" + CONTENT_AUTHORITY + "/" + PATH_BOOKS;
    public static final String CONTENT_ITEM_TYPE =
        "vnd.android.cursor.item/" + CONTENT_AUTHORITY + "/" + PATH_BOOKS;

    public static final String TABLE_NAME = "books";

    public static final String TITLE = "title";

    public static final String IMAGE_URL = "imgurl";

    public static final String SUBTITLE = "subtitle";

    public static final String DESC = "description";

    public static Uri buildBookUri(long id) {
      return ContentUris.withAppendedId(CONTENT_URI, id);
    }

    public static Uri buildFullBookUri(long id) {
      return ContentUris.withAppendedId(FULL_CONTENT_URI, id);
    }
  }
    public static void init(Context context) {
      AUTHORITY = context.getString(R.string.wheelmapprovider);

      CONTENT_URI_BASE = Uri.parse(ContentResolver.SCHEME_CONTENT + "://" + AUTHORITY);
      CONTENT_URI_ALL = CONTENT_URI_BASE.buildUpon().appendPath(PATH_ALL).build();
      CONTENT_URI_RETRIEVED = CONTENT_URI_BASE.buildUpon().appendPath(PATH_RETRIEVED).build();
      CONTENT_URI_COPY = CONTENT_URI_BASE.buildUpon().appendPath(PATH_COPY).build();
      CONTENT_URI_TMP = CONTENT_URI_BASE.buildUpon().appendPath(PATH_TMP).build();
    }
  public void process(HttpClient client) throws ClientProtocolException, IOException {
    Uri uri = Uri.parse(BASE_URI + LOCATION_PATH);
    uri = uri.buildUpon().appendQueryParameter(PARAM_SESSION, location.getSession()).build();
    uri = uri.buildUpon().appendQueryParameter(PARAM_PERSON, location.getPerson()).build();
    uri = uri.buildUpon().appendQueryParameter(PARAM_NAME, location.getName()).build();
    uri = uri.buildUpon().appendQueryParameter(PARAM_LATITUDE, location.getLatitude()).build();
    uri = uri.buildUpon().appendQueryParameter(PARAM_LONGITUDE, location.getLongitude()).build();

    HttpPut request = new HttpPut(uri.toString());

    ResponseHandler<String> handler = new BasicResponseHandler();

    client.execute(request, handler);
  }
Example #7
0
  public static final class PhoneEntry implements BaseColumns {

    public static final Uri CONTENT_URI =
        BASE_CONTENT_URI.buildUpon().appendPath(PATH_PHONE).build();

    public static final String CONTENT_TYPE =
        ContentResolver.CURSOR_DIR_BASE_TYPE + "/" + CONTENT_AUTHORITY + "/" + PATH_PHONE;

    public static final String TABLE_NAME = "phones";

    public static final String COLUMN_CLIENT_ID = "client_id";
    public static final String COLUMN_NAME = "name";
    public static final String COLUMN_DESCR = "descr";
    public static final String COLUMN_PHONE = "phone";

    public static Uri buildUri(long id) {
      return ContentUris.withAppendedId(CONTENT_URI, id);
    }

    public static Uri buildClientUri(String ClientID) {
      return CONTENT_URI.buildUpon().appendPath(ClientID).build();
    }

    public static String getClientFromUri(Uri uri) {
      return uri.getPathSegments().get(1);
    }
  }
 private static Uri asCalendarSyncAdapter(Uri uri, String account, String accountType) {
   return uri.buildUpon()
       .appendQueryParameter(CalendarContract.CALLER_IS_SYNCADAPTER, "true")
       .appendQueryParameter(Calendars.ACCOUNT_NAME, account)
       .appendQueryParameter(Calendars.ACCOUNT_TYPE, accountType)
       .build();
 }
  public static final class FavoriteEntry implements BaseColumns {
    public static final Uri CONTENT_URI =
        BASE_CONTENT_URI.buildUpon().appendPath(PATH_FAVORITE).build();

    public static final String CONTENT_TYPE =
        ContentResolver.CURSOR_DIR_BASE_TYPE + "/" + CONTENT_AUTHORITY + "/" + PATH_FAVORITE;

    public static final String TABLE_NAME = "favorite";

    public static final String COLUMN_MOVIE_ID = "movie_id";

    public static final String COLUMN_POPULARITY = "popularity";

    public static final String COLUMN_ORIGINAL_TITLE = "original_title";

    public static final String COLUMN_POSTER_PATH = "poster_path";

    public static final String COLUMN_PLOT_SYNOPSIS = "plot_synopsis";

    public static final String COLUMN_VOTE_AVERAGE = "vote_average";

    public static final String COLUMN_RELEASE_DATE = "release_date";

    public static long getMovieIdFromUri(Uri uri) {
      return Long.parseLong(uri.getPathSegments().get(1));
    }
  }
Example #10
0
  /** Represents a campaign. */
  public static final class Campaigns implements BaseColumns, CampaignColumns {

    public static final Uri CONTENT_URI =
        BASE_CONTENT_URI.buildUpon().appendPath(PATH_CAMPAIGNS).build();
    public static final String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.ohmage.campaign";
    public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/vnd.ohmage.campaign";

    /** Default "ORDER BY" clause. */
    public static final String DEFAULT_SORT = CampaignColumns.CAMPAIGN_NAME;

    /** Build {@link Uri} for requested {@link #CAMPAIGN_URN} */
    public static Uri buildCampaignUri(String campaignUrn) {
      return CONTENT_URI.buildUpon().appendPath(campaignUrn).build();
    }

    /**
     * Build {@link Uri} that references any {@link Surveys} associated with the requested {@link
     * #CAMPAIGN_URN}.
     */
    public static Uri buildSurveysUri(String campaignUrn) {
      return CONTENT_URI.buildUpon().appendPath(campaignUrn).appendPath(PATH_SURVEYS).build();
    }

    /**
     * Build {@link Uri} that references any {@link Surveys} associated with the requested {@link
     * #CAMPAIGN_URN} and {@link Surveys#SURVEY_ID}
     */
    public static Uri buildSurveysUri(String campaignUrn, String surveyId) {
      return buildSurveysUri(campaignUrn).buildUpon().appendPath(surveyId).build();
    }

    /**
     * Build {@link Uri} that references any {@link SurveyPrompts} associated with the requested
     * {@link #CAMPAIGN_URN} and {@link Surveys#SURVEY_ID}
     */
    public static Uri buildSurveyPromptsUri(String campaignUrn, String surveyId) {
      return buildSurveysUri(campaignUrn, surveyId).buildUpon().appendPath(PATH_SURVEYS).build();
    }

    /**
     * Build {@link Uri} that references any {@link Responses} associated with the requested {@link
     * #CAMPAIGN_URN}
     */
    public static Uri buildResponsesUri(String campaignUrn) {
      return CONTENT_URI.buildUpon().appendPath(campaignUrn).appendPath(PATH_RESPONSES).build();
    }

    /**
     * Build {@link Uri} that references any {@link Responses} associated with the requested {@link
     * #CAMPAIGN_URN} and {@link Surveys#SURVEY_ID}
     */
    public static Uri buildResponsesUri(String campaignUrn, String surveyId) {
      return buildSurveysUri(campaignUrn, surveyId).buildUpon().appendPath(PATH_RESPONSES).build();
    }

    /** Read {@link #CAMPAIGN_URN} from {@link Campaigns} {@link Uri}. */
    public static String getCampaignUrn(Uri uri) {
      return uri.getPathSegments().get(1);
    }
  }
 public static Uri buildUriByMovieId(long movieId) {
   return CONTENT_URI
       .buildUpon()
       .appendPath(PATH_MOVIE)
       .appendPath(Long.toString(movieId))
       .build();
 }
Example #12
0
 public static Uri buildAdvertisementwithLocation(String countryCode, String zipCode) {
   return CONTENT_URI
       .buildUpon()
       .appendQueryParameter(COLUMN_COUNTRY_CODE, countryCode)
       .appendQueryParameter(COLUMN_ZIP_CODE, zipCode)
       .build();
 }
Example #13
0
 public static Uri getParent(Uri u) {
   if (u == null) return null;
   final List<String> paths = u.getPathSegments();
   final int n = paths.size();
   if (n < 4) return null;
   StringBuffer sb = new StringBuffer();
   for (int i = 0; i < n - 1; i++) {
     sb.append("/");
     sb.append(paths.get(i));
   }
   if (n == 4) {
     String last = paths.get(n - 1);
     int col_pos = last.lastIndexOf(':');
     if (!(col_pos <= 0 || col_pos == last.length() - 1)) {
       sb.append("/");
       sb.append(last.substring(0, col_pos + 1));
       String subpath = last.substring(col_pos + 1);
       subpath = Uri.decode(subpath);
       int sl_pos = subpath.lastIndexOf(SLC);
       if (sl_pos > 0) {
         subpath = subpath.substring(0, sl_pos);
         sb.append(Uri.encode(subpath));
       }
     }
     return u.buildUpon().encodedPath(sb.toString()).build();
   }
   return null;
 }
Example #14
0
  public static Uri withExtendedPath(Uri uri, String[] path) {
    Uri.Builder builder = uri.buildUpon();

    for (String p : path) builder.appendPath(p);

    return builder.build();
  }
    /* Inner class that defines the table contents of the location table */
    public static final class BreakfastEntry implements BaseColumns {

        public static final Uri CONTENT_URI =
                BASE_CONTENT_URI.buildUpon().appendPath(PATH_BREAKFAST).build();

        public static final String CONTENT_TYPE =
                ContentResolver.CURSOR_DIR_BASE_TYPE + "/" + CONTENT_AUTHORITY + "/" + PATH_BREAKFAST;
        // can be removed as breafst contasins list of items so dir is preferred
        public static final String CONTENT_ITEM_TYPE =
                ContentResolver.CURSOR_ITEM_BASE_TYPE + "/" + CONTENT_AUTHORITY + "/" + PATH_BREAKFAST;

        // Table name
        public static final String TABLE_NAME = "Breakfast";

        // The location setting string is what will be sent to openweathermap
        // as the location query.

        public static final String COLUMN_ITEM_NAME = "item_name";


        public static final String COLUMN_ITEM_RATING = "item_rating";
        public static Uri buildBreakfastUri(long id) {
            return ContentUris.withAppendedId(CONTENT_URI, id);
        }
    }
    /* Inner class that defines the table contents of the weather table */
    public static final class MenuEntry implements BaseColumns {

        public static final Uri CONTENT_URI =
                BASE_CONTENT_URI.buildUpon().appendPath(PATH_DATE).build();

        public static final String CONTENT_TYPE =
                ContentResolver.CURSOR_DIR_BASE_TYPE + "/" + CONTENT_AUTHORITY + "/" + PATH_DATE;
        public static final String CONTENT_ITEM_TYPE =
                ContentResolver.CURSOR_ITEM_BASE_TYPE + "/" + CONTENT_AUTHORITY + "/" + PATH_DATE;

        public static final String TABLE_NAME = "Menu";

        // Column with the foreign key into the location table.

        public static final String COLUMN_BRE_KEY = "location_id";
        public static final String COLUMN_LUN_KEY = "location_id"; public static final String COLUMN_DIN_KEY = "location_id";
        // Date, stored as long in milliseconds since the epoch
        public static final String COLUMN_DATE = "date";
        // Weather id as returned by API, to identify the icon to be used
        public static final String COLUMN_MENU_ID = "menu_id";

        public static String getMealTypeFromUri(Uri uri) {
            return uri.getPathSegments().get(2);
        }

        public static long getDateFromUri(Uri uri) {
            return Long.parseLong(uri.getPathSegments().get(1));
        }



        }
Example #17
0
  /**
   * Represents a survey response.
   *
   * <p>The 'source' field indicates how the survey response was added to the database. If it's
   * "local", that means that the survey was filled out by the user and is awaiting upload. If it's
   * "remote", it means that it was downloaded by the feedback sync service. Both "local" and
   * "remote" surveys are used for generating feedback visualizations.
   *
   * <p>The 'uploaded' field indicates whether or not the survey has been uploaded by the {@link
   * OldUploadService} yet. This field is valid only for records where 'source' is "local".
   */
  public static final class Responses implements BaseColumns, ResponseColumns {

    public static final Uri CONTENT_URI =
        BASE_CONTENT_URI.buildUpon().appendPath(PATH_RESPONSES).build();
    public static final String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.ohmage.response";
    public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/vnd.ohmage.response";

    public static final String CAMPAIGN_URN = "campaign_urn";
    public static final String SURVEY_ID = "survey_id";

    /** Build {@link Uri} for requested {@link Responses#_ID} */
    public static Uri buildResponseUri(long responseId) {
      return ContentUris.withAppendedId(CONTENT_URI, responseId);
    }

    /**
     * Build {@link Uri} that references any {@link Responses} associated with the requested {@link
     * Responses#_ID}
     */
    public static Uri buildPromptResponsesUri(long responseId) {
      return buildResponseUri(responseId).buildUpon().appendPath(PATH_PROMPTS).build();
    }

    /** Read ResponseId from {@link Responses} {@link Uri}. */
    public static String getResponseId(Uri uri) {
      return uri.getPathSegments().get(1);
    }

    /** Checks to see if the given uri is a {@link Responses} uri */
    public static boolean isResponseUri(Uri uri) {
      if (uri == null) return false;
      List<String> segments = uri.getPathSegments();
      return segments != null && segments.size() > 0 && PATH_RESPONSES.equals(segments.get(0));
    }
  }
Example #18
0
  /**
   * Common method for performing a query of the music database, called for both top-level queries
   * and filtering.
   *
   * @param sync If true, this query should be done synchronously and the resulting cursor returned.
   *     If false, it will be done asynchronously and null returned.
   * @param filterstring If non-null, this is a filter to apply to the query.
   */
  Cursor doQuery(boolean sync, String filterstring) {
    // Cancel any pending queries
    mQueryHandler.cancelOperation(MY_QUERY_TOKEN);

    StringBuilder where = new StringBuilder();
    where.append(MediaStore.Audio.Media.TITLE + " != ''");

    // We want to show all audio files, even recordings.  Enforcing the
    // following condition would hide recordings.
    // where.append(" AND " + MediaStore.Audio.Media.IS_MUSIC + "=1");

    Uri uri = mBaseUri;
    if (!TextUtils.isEmpty(filterstring)) {
      uri = uri.buildUpon().appendQueryParameter("filter", Uri.encode(filterstring)).build();
    }

    if (sync) {
      try {
        return getContentResolver().query(uri, CURSOR_COLS, where.toString(), null, mSortOrder);
      } catch (UnsupportedOperationException ex) {
      }
    } else {
      mAdapter.setLoading(true);
      setProgressBarIndeterminateVisibility(true);
      mQueryHandler.startQuery(
          MY_QUERY_TOKEN, null, uri, CURSOR_COLS, where.toString(), null, mSortOrder);
    }
    return null;
  }
 public static Uri buildWeatherLocationWithDate(String locationQuery, long testDate) {
   return CONTENT_URI
       .buildUpon()
       .appendPath(locationQuery)
       .appendPath(Long.toString(normalizeDate(testDate)))
       .build();
 }
 public static Uri buildWeatherLocationWithStartDate(String locationSetting, String startDate) {
   return CONTENT_URI
       .buildUpon()
       .appendPath(locationSetting)
       .appendQueryParameter(COLUMN_DATETEXT, startDate)
       .build();
 }
  public static final class LocationEntry implements BaseColumns {
    public static final Uri CONTENT_URI =
        BASE_CONTENT_URI.buildUpon().appendPath(PATH_LOCATION).build();

    public static final String CONTENT_TYPE =
        "vnd.android.cursor.dir/" + CONTENT_AUTHORITY + "/" + PATH_LOCATION;

    public static final String CONTENT_ITEM_TYPE =
        "vnd.android.cursor.item/" + CONTENT_AUTHORITY + "/" + PATH_LOCATION;

    // Table name
    public static final String TABLE_NAME = "location";

    // The location setting string is what will be sent to openweathermap
    // as the location query.
    public static final String COLUMN_LOCATION_SETTING = "location_setting";

    // Human readable location string, provided by the API.  Because for styling,
    // "Mountain View" is more recognizable than 94043.
    public static final String COLUMN_CITY_NAME = "city_name";

    // In order to uniquely pinpoint the location on the map when we launch the
    // map intent, we store the latitude and longitude as returned by openweathermap.
    public static final String COLUMN_COORD_LAT = "coord_lat";
    public static final String COLUMN_COORD_LONG = "coord_long";

    public static Uri buildLocationUri(long id) {
      return ContentUris.withAppendedId(CONTENT_URI, id);
    }
  }
Example #22
0
  public static final class CallEntry implements BaseColumns {

    public static final Uri CONTENT_URI =
        BASE_CONTENT_URI.buildUpon().appendPath(PATH_CALL).build();

    public static final String CONTENT_TYPE =
        ContentResolver.CURSOR_DIR_BASE_TYPE + "/" + CONTENT_AUTHORITY + "/" + PATH_CALL;
    public static final String CONTENT_ITEM_TYPE =
        ContentResolver.CURSOR_ITEM_BASE_TYPE + "/" + CONTENT_AUTHORITY + "/" + PATH_CALL;

    public static final String TABLE_NAME = "calls";

    public static final String COLUMN_ID_1C = "_id_1c";
    public static final String COLUMN_DATE = "date";
    public static final String COLUMN_CAR_ID = "car_id";
    public static final String COLUMN_CLIENT_ID = "client_id";
    public static final String COLUMN_TYPE = "type";
    public static final String COLUMN_REASON = "reason";
    public static final String COLUMN_SUM = "sum";
    public static final String COLUMN_INTERVIEW_ID = "interview_id";
    public static final String COLUMN_DONE = "done";

    public static Uri buildUri(long id) {
      return ContentUris.withAppendedId(CONTENT_URI, id);
    }

    public static Uri buildCallID(int id) {
      return CONTENT_URI.buildUpon().appendPath(Integer.toString(id)).build();
    }

    public static String getIDFromUri(Uri uri) {
      return uri.getPathSegments().get(1);
    }
  }
  public static final class MovieEntry implements BaseColumns {
    public static final String TABLE_NAME = "movie";

    public static final String COLUMN_TMDB_ID = "tmdb_id";
    public static final String COLUMN_POSTER_PATH = "poster_path";
    public static final String COLUMN_ORIGINAL_TITLE = "original_title";
    public static final String COLUMN_RELEASE_DATE = "release_date";
    public static final String COLUMN_VOTE_AVERAGE = "vote_average";
    public static final String COLUMN_OVERVIEW = "overview";

    public static final Uri CONTENT_URI =
        BASE_CONTENT_URI.buildUpon().appendPath(PATH_MOVIE).build();

    public static final String CONTENT_TYPE =
        ContentResolver.CURSOR_DIR_BASE_TYPE + "/" + CONTENT_AUTHORITY + "/" + PATH_MOVIE;
    public static final String CONTENT_ITEM_TYPE =
        ContentResolver.CURSOR_ITEM_BASE_TYPE + "/" + CONTENT_AUTHORITY + "/" + PATH_MOVIE;

    public static Uri buildMovieUri(int tmdbId) {
      return ContentUris.withAppendedId(CONTENT_URI, tmdbId);
    }

    public static int getTmdbIdFromUri(Uri uri) {
      return Integer.parseInt(uri.getPathSegments().get(1));
    }
  }
Example #24
0
  public static final class StateEntry implements BaseColumns {

    public static final Uri CONTENT_URI =
        BASE_CONTENT_URI.buildUpon().appendPath(PATH_STATE).build();

    public static final String CONTENT_TYPE =
        ContentResolver.CURSOR_DIR_BASE_TYPE + "/" + CONTENT_AUTHORITY + "/" + PATH_STATE;

    public static final String TABLE_NAME = "states";

    public static final String COLUMN_DOC_ID_1C = "doc_id";
    public static final String COLUMN_DATE = "date";
    public static final String COLUMN_STATUS = "status_id";
    public static final String COLUMN_USER = "user_name";

    public static Uri buildUri(long id) {
      return ContentUris.withAppendedId(CONTENT_URI, id);
    }

    public static Uri buildDocUri(String docId) {
      return CONTENT_URI.buildUpon().appendPath(docId).build();
    }

    public static String getDocFromUri(Uri uri) {
      return uri.getPathSegments().get(1);
    }
  }
Example #25
0
  private static Media getLastImageThumbnail(ContentResolver resolver) {
    Uri baseUri = Images.Media.EXTERNAL_CONTENT_URI;
    Log.d("mk", "getLastImageThumbnail() = " + baseUri.toString());
    Log.d("mk", "DCIM = " + Storage.DCIM.toString());
    Uri query = baseUri.buildUpon().appendQueryParameter("limit", "1").build();
    String[] projection =
        new String[] {ImageColumns._ID, ImageColumns.ORIENTATION, ImageColumns.DATE_TAKEN};
    String selection =
        ImageColumns.MIME_TYPE
            + "='image/jpeg'"
            + "AND "
            + ImageColumns.BUCKET_ID
            + "="
            + Storage.getBucketId(Storage.FILE_TYPE_PHOTO);
    // ImageColumns.BUCKET_DISPLAY_NAME + "='Photo'";
    String order = ImageColumns.DATE_TAKEN + " DESC," + ImageColumns._ID + " DESC";

    Cursor cursor = null;
    try {
      cursor = resolver.query(query, projection, selection, null, order);
      if (cursor != null && cursor.moveToFirst()) {
        long id = cursor.getLong(0);
        return new Media(
            id, cursor.getInt(1), cursor.getLong(2), ContentUris.withAppendedId(baseUri, id));
      }
      Log.d("dyb", "cursor null");
    } finally {
      if (cursor != null) {
        cursor.close();
      }
    }
    return null;
  }
Example #26
0
  public static final class OperationEntry implements BaseColumns {

    public static final Uri CONTENT_URI =
        BASE_CONTENT_URI.buildUpon().appendPath(PATH_OPERATION).build();

    public static final String CONTENT_TYPE =
        ContentResolver.CURSOR_DIR_BASE_TYPE + "/" + CONTENT_AUTHORITY + "/" + PATH_OPERATION;

    public static final String TABLE_NAME = "operations";

    public static final String COLUMN_CODE_1C = "code_1c";
    public static final String COLUMN_DOC_ID_1C = "doc_id";
    public static final String COLUMN_LINENUM = "linenumber";
    public static final String COLUMN_NAME = "name";
    public static final String COLUMN_AMOUNT = "amount";
    public static final String COLUMN_SUM = "sum";
    public static final String COLUMN_STATUS = "status";

    public static Uri buildUri(long id) {
      return ContentUris.withAppendedId(CONTENT_URI, id);
    }

    public static Uri buildDocUri(String docId) {
      return CONTENT_URI.buildUpon().appendPath(docId).build();
    }

    public static String getDocFromUri(Uri uri) {
      return uri.getPathSegments().get(1);
    }
  }
Example #27
0
  /**
   * Adds two query parameters into the Uri, namely the language code and the version code of the
   * app's package as gotten via the context.
   *
   * @return the uri with added query parameters
   */
  private static Uri uriWithAddedParameters(Context context, Uri baseUri) {
    Uri.Builder builder = baseUri.buildUpon();

    // Add in the preferred language
    builder.appendQueryParameter(PARAM_LANGUAGE_CODE, Locale.getDefault().toString());

    // Add in the package version code
    if (sCachedVersionCode == null) {
      // There is no cached version code, so try to get it from the package manager.
      try {
        // cache the version code
        PackageInfo info = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
        sCachedVersionCode = Integer.toString(info.versionCode);

        // append the version code to the uri
        builder.appendQueryParameter(PARAM_VERSION, sCachedVersionCode);
      } catch (NameNotFoundException e) {
        // Cannot find the package name, so don't add in the version parameter
        // This shouldn't happen.
        Log.wtf("Invalid package name for context " + e);
      }
    } else {
      builder.appendQueryParameter(PARAM_VERSION, sCachedVersionCode);
    }

    // Build the full uri and return it
    return builder.build();
  }
Example #28
0
  public static final class QuestionEntry implements BaseColumns {

    public static final Uri CONTENT_URI =
        BASE_CONTENT_URI.buildUpon().appendPath(PATH_QUESTION).build();

    public static final String CONTENT_TYPE =
        ContentResolver.CURSOR_DIR_BASE_TYPE + "/" + CONTENT_AUTHORITY + "/" + PATH_QUESTION;

    public static final String TABLE_NAME = "questions";

    public static final String COLUMN_INTERVIEW_ID = "interview_id";
    public static final String COLUMN_ID_1C = "_id_1c";
    public static final String COLUMN_NAME = "name";
    public static final String COLUMN_SPEECH = "speech";

    public static Uri buildUri(long id) {
      return ContentUris.withAppendedId(CONTENT_URI, id);
    }

    public static Uri buildInterviewUri(String InterviewId) {
      return CONTENT_URI.buildUpon().appendPath(InterviewId).build();
    }

    public static String getInterviewFromUri(Uri uri) {
      return uri.getPathSegments().get(1);
    }
  }
Example #29
0
 public static Uri buildWeatherLocationWithDate(String locationSetting, long date) {
   return CONTENT_URI
       .buildUpon()
       .appendPath(locationSetting)
       .appendPath(Long.toString(normalizeDate(date)))
       .build();
 }
Example #30
0
  public static final class AnswerEntry implements BaseColumns {

    public static final Uri CONTENT_URI =
        BASE_CONTENT_URI.buildUpon().appendPath(PATH_ANSWER).build();

    public static final String CONTENT_TYPE =
        ContentResolver.CURSOR_DIR_BASE_TYPE + "/" + CONTENT_AUTHORITY + "/" + PATH_ANSWER;

    public static final String TABLE_NAME = "answers";

    public static final String COLUMN_QUESTION_ID = "question_id";
    public static final String COLUMN_ID_1C = "_id_1c";
    public static final String COLUMN_NAME = "name";

    public static Uri buildUri(long id) {
      return ContentUris.withAppendedId(CONTENT_URI, id);
    }

    public static Uri buildQuestionUri(String QuestionId) {
      return CONTENT_URI.buildUpon().appendPath(QuestionId).build();
    }

    public static String getQuestionFromUri(Uri uri) {
      return uri.getPathSegments().get(1);
    }
  }