Example #1
0
  public static boolean containAudioTrack(Context context, String path) {
    Cursor cursor =
        ContentResolverCompat.query(
            context.getContentResolver(),
            MediaCenterProvider.AUDIO_TRACKS_TABLE_CONTENT_URI,
            null,
            MediaCenterProvider.TRACK_PATH + "=" + "'" + path + "'",
            null,
            null,
            null);

    boolean contain = cursor.getCount() > 0;

    cursor.close();

    return contain;
  }
Example #2
0
  public static String getDownloadFolderID(Context context) {
    Cursor cursor =
        ContentResolverCompat.query(
            context.getContentResolver(),
            MediaCenterProvider.AUDIO_FOLDERS_TABLE_CONTENT_URI,
            new String[] {MediaCenterProvider.ID},
            MediaCenterProvider.FOLDER_PATH
                + "="
                + "'"
                + CacheManager.CHECK_DOWNLOADS_FOLDER_PATH
                + "'",
            null,
            null,
            null);

    cursor.moveToFirst();
    String id = cursor.getString(cursor.getColumnIndex(MediaCenterProvider.ID));
    cursor.close();

    return id;
  }
Example #3
0
  public static List<String> getFoldersPath(Context context) {
    Cursor cursor =
        ContentResolverCompat.query(
            context.getContentResolver(),
            MediaCenterProvider.AUDIO_FOLDERS_TABLE_CONTENT_URI,
            new String[] {MediaCenterProvider.FOLDER_PATH},
            null,
            null,
            null,
            null);
    List<String> paths = null;
    if (cursor.getCount() > 0) {
      paths = new ArrayList<>();
      cursor.moveToPosition(-1);
      while (cursor.moveToNext()) {
        String path = cursor.getString(cursor.getColumnIndex(MediaCenterProvider.FOLDER_PATH));
        paths.add(path);
      }
    }
    cursor.close();

    return paths;
  }