当前位置: 首页>>代码示例>>Java>>正文


Java PlaylistsColumns.NAME属性代码示例

本文整理汇总了Java中android.provider.MediaStore.Audio.PlaylistsColumns.NAME属性的典型用法代码示例。如果您正苦于以下问题:Java PlaylistsColumns.NAME属性的具体用法?Java PlaylistsColumns.NAME怎么用?Java PlaylistsColumns.NAME使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在android.provider.MediaStore.Audio.PlaylistsColumns的用法示例。


在下文中一共展示了PlaylistsColumns.NAME属性的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createPlaylist

/**
 * @param context The {@link Context} to use.
 * @param name    The name of the new playlist.
 * @return A new playlist ID.
 */
public static final long createPlaylist(final Context context, final String name) {
    if (name != null && name.length() > 0) {
        final ContentResolver resolver = context.getContentResolver();
        final String[] projection = new String[]{
                PlaylistsColumns.NAME
        };
        final String selection = PlaylistsColumns.NAME + " = '" + name + "'";
        Cursor cursor = resolver.query(MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI,
                projection, selection, null, null);
        if (cursor.getCount() <= 0) {
            final ContentValues values = new ContentValues(1);
            values.put(PlaylistsColumns.NAME, name);
            final Uri uri = resolver.insert(MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI,
                    values);
            return Long.parseLong(uri.getLastPathSegment());
        }
        if (cursor != null) {
            cursor.close();
            cursor = null;
        }
        return -1;
    }
    return -1;
}
 
开发者ID:komamj,项目名称:KomaMusic,代码行数:29,代码来源:MusicUtils.java

示例2: createPlaylist

/**
 * @param context
 * @param name
 * @return
 */
public static long createPlaylist(Context context, String name) {

    if (name != null && name.length() > 0) {
        ContentResolver resolver = context.getContentResolver();
        String[] cols = new String[] {
            PlaylistsColumns.NAME
        };
        String whereclause = PlaylistsColumns.NAME + " = '" + name + "'";
        Cursor cur = resolver.query(Audio.Playlists.EXTERNAL_CONTENT_URI, cols, whereclause,
                null, null);
        if (cur.getCount() <= 0) {
            ContentValues values = new ContentValues(1);
            values.put(PlaylistsColumns.NAME, name);
            Uri uri = resolver.insert(Audio.Playlists.EXTERNAL_CONTENT_URI, values);
            return Long.parseLong(uri.getLastPathSegment());
        }
        return -1;
    }
    return -1;
}
 
开发者ID:cpoopc,项目名称:com.cp.monsterMod,代码行数:25,代码来源:MusicUtils.java

示例3: getFavoritesId

/**
 * @param context
 * @return
 */
public static long getFavoritesId(Context context) {
    long favorites_id = -1;
    String favorites_where = PlaylistsColumns.NAME + "='" + "Favorites" + "'";
    String[] favorites_cols = new String[] {
        BaseColumns._ID
    };
    Uri favorites_uri = Audio.Playlists.EXTERNAL_CONTENT_URI;
    Cursor cursor = query(context, favorites_uri, favorites_cols, favorites_where, null, null);
    if (cursor.getCount() <= 0) {
        favorites_id = createPlaylist(context, "Favorites");
    } else {
        cursor.moveToFirst();
        favorites_id = cursor.getLong(0);
        cursor.close();
    }
    return favorites_id;
}
 
开发者ID:cpoopc,项目名称:com.cp.monsterMod,代码行数:21,代码来源:MusicUtils.java

示例4: removeFromFavorites

/**
 * @param context
 * @param id
 */
public static void removeFromFavorites(Context context, long id) {
    long favorites_id;
    if (id < 0) {
    } else {
        ContentResolver resolver = context.getContentResolver();
        String favorites_where = PlaylistsColumns.NAME + "='" + PLAYLIST_NAME_FAVORITES + "'";
        String[] favorites_cols = new String[] {
            BaseColumns._ID
        };
        Uri favorites_uri = Audio.Playlists.EXTERNAL_CONTENT_URI;
        Cursor cursor = resolver.query(favorites_uri, favorites_cols, favorites_where, null,
                null);
        if (cursor.getCount() <= 0) {
            favorites_id = createPlaylist(context, PLAYLIST_NAME_FAVORITES);
        } else {
            cursor.moveToFirst();
            favorites_id = cursor.getLong(0);
            cursor.close();
        }
        Uri uri = Playlists.Members.getContentUri(EXTERNAL, favorites_id);
        resolver.delete(uri, Playlists.Members.AUDIO_ID + "=" + id, null);
    }
}
 
开发者ID:cpoopc,项目名称:com.cp.monsterMod,代码行数:27,代码来源:MusicUtils.java

示例5: getPlaylistName

/**
 * @param playlist_id
 * @return playlist name
 */
public static String getPlaylistName(Context mContext, long playlist_id) {
    String where = BaseColumns._ID + "=" + playlist_id;
    String[] cols = new String[] {
        PlaylistsColumns.NAME
    };
    Uri uri = Audio.Playlists.EXTERNAL_CONTENT_URI;
    Cursor cursor = mContext.getContentResolver().query(uri, cols, where, null, null);
    if (cursor == null){
        return "";
    }
    if (cursor.getCount() <= 0)
        return "";
    cursor.moveToFirst();
    String name = cursor.getString(0);
    cursor.close();
    return name;
}
 
开发者ID:C-Aniruddh,项目名称:xPlodMusic,代码行数:21,代码来源:MusicUtils.java

示例6: createPlaylist

/**
 * @param context The {@link Context} to use.
 * @param name The name of the new playlist.
 * @return A new playlist ID.
 */
public static long createPlaylist(final Context context, final String name) {
    if (name != null && name.length() > 0) {
        final ContentResolver resolver = context.getContentResolver();
        final String[] projection = new String[] {
            PlaylistsColumns.NAME
        };
        final String selection = PlaylistsColumns.NAME + " = '" + name + "'";
        Cursor cursor = resolver.query(MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI,
                projection, selection, null, null);
        int count = 1;
        if (cursor != null) {
            count = cursor.getCount();
            cursor.close();
        }
        if (count <= 0) {
            final ContentValues values = new ContentValues(1);
            values.put(PlaylistsColumns.NAME, name);
            final Uri uri = resolver.insert(MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI,
                    values);
            return Long.parseLong(uri.getLastPathSegment());
        }
        return -1;
    }
    return -1;
}
 
开发者ID:OpenSilk,项目名称:Orpheus,代码行数:30,代码来源:MusicUtils.java

示例7: createPlaylist

/**
 * @param context The {@link Context} to use.
 * @param name The name of the new playlist.
 * @return A new playlist ID.
 */
public static final long createPlaylist(final Context context, final String name) {
    if (name != null && name.length() > 0) {
        final ContentResolver resolver = context.getContentResolver();
        final String[] projection = new String[] {
            PlaylistsColumns.NAME
        };
        final String selection = PlaylistsColumns.NAME + " = '" + name + "'";
        Cursor cursor = resolver.query(MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI,
                projection, selection, null, null);
        if (cursor.getCount() <= 0) {
            final ContentValues values = new ContentValues(1);
            values.put(PlaylistsColumns.NAME, name);
            final Uri uri = resolver.insert(MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI,
                    values);
            return Long.parseLong(uri.getLastPathSegment());
        }
        if (cursor != null) {
            cursor.close();
            cursor = null;
        }
        return -1;
    }
    return -1;
}
 
开发者ID:micromacer,项目名称:Player-by-TweekProject,代码行数:29,代码来源:MusicUtils.java

示例8: setupFragmentData

public void setupFragmentData(){
    mAdapter = new PlaylistAdapter(getActivity(), R.layout.music_listview_items, null,
            										new String[] {}, new int[] {}, 0);
	mProjection = new String[] {
            BaseColumns._ID, PlaylistsColumns.NAME
    };
    mSortOrder = Audio.Playlists.DEFAULT_SORT_ORDER;
    mUri = Audio.Playlists.EXTERNAL_CONTENT_URI;
    mFragmentGroupId = 5;
    mType = TYPE_PLAYLIST;
    mTitleColumn = PlaylistsColumns.NAME;         
}
 
开发者ID:hubcarl,项目名称:mobile-manager-tool,代码行数:12,代码来源:PlaylistsFragment.java

示例9: setupFragmentData

public void setupFragmentData(){
    mAdapter = new PlaylistAdapter(getActivity(), R.layout.listview_items, null,
            										new String[] {}, new int[] {}, 0);
	mProjection = new String[] {
            BaseColumns._ID, PlaylistsColumns.NAME
    };
    mSortOrder = Audio.Playlists.DEFAULT_SORT_ORDER;
    mUri = Audio.Playlists.EXTERNAL_CONTENT_URI;
    mFragmentGroupId = 5;
    mType = TYPE_PLAYLIST;
    mTitleColumn = PlaylistsColumns.NAME;         
}
 
开发者ID:C-Aniruddh,项目名称:xPlodMusic,代码行数:12,代码来源:PlaylistsFragment.java

示例10: onCreateLoader

@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    String[] projection = new String[] {
            BaseColumns._ID, PlaylistsColumns.NAME
    };
    Uri uri = Audio.Playlists.EXTERNAL_CONTENT_URI;
    String sortOrder = Audio.Playlists.DEFAULT_SORT_ORDER;
    return new CursorLoader(getActivity(), uri, projection, null, null, sortOrder);
}
 
开发者ID:liufeiit,项目名称:itmarry,代码行数:9,代码来源:PlaylistsFragment.java

示例11: addToFavorites

/**
 * @param context
 * @param id
 */
public static void addToFavorites(Context context, long id) {

    long favorites_id;

    if (id < 0) {

    } else {
        ContentResolver resolver = context.getContentResolver();

        String favorites_where = PlaylistsColumns.NAME + "='" + PLAYLIST_NAME_FAVORITES + "'";
        String[] favorites_cols = new String[] {
            BaseColumns._ID
        };
        Uri favorites_uri = Audio.Playlists.EXTERNAL_CONTENT_URI;
        Cursor cursor = resolver.query(favorites_uri, favorites_cols, favorites_where, null,
                null);
        if (cursor.getCount() <= 0) {
            favorites_id = createPlaylist(context, PLAYLIST_NAME_FAVORITES);
        } else {
            cursor.moveToFirst();
            favorites_id = cursor.getLong(0);
            cursor.close();
        }

        String[] cols = new String[] {
            Playlists.Members.AUDIO_ID
        };
        Uri uri = Playlists.Members.getContentUri(EXTERNAL, favorites_id);
        Cursor cur = resolver.query(uri, cols, null, null, null);

        int base = cur.getCount();
        cur.moveToFirst();
        while (!cur.isAfterLast()) {
            if (cur.getLong(0) == id)
                return;
            cur.moveToNext();
        }
        cur.close();

        ContentValues values = new ContentValues();
        values.put(Playlists.Members.AUDIO_ID, id);
        values.put(Playlists.Members.PLAY_ORDER, base + 1);
        resolver.insert(uri, values);
    }
}
 
开发者ID:cpoopc,项目名称:com.cp.monsterMod,代码行数:49,代码来源:MusicUtils.java

示例12: isFavorite

/**
 * @param context
 * @param id
 * @return
 */
public static boolean isFavorite(Context context, long id) {

    long favorites_id;

    if (id < 0) {

    } else {
        ContentResolver resolver = context.getContentResolver();

        String favorites_where = PlaylistsColumns.NAME + "='" + PLAYLIST_NAME_FAVORITES + "'";
        String[] favorites_cols = new String[] {
            BaseColumns._ID
        };
        Uri favorites_uri = Audio.Playlists.EXTERNAL_CONTENT_URI;
        Cursor cursor = resolver.query(favorites_uri, favorites_cols, favorites_where, null,
                null);
        if (cursor.getCount() <= 0) {
            favorites_id = createPlaylist(context, PLAYLIST_NAME_FAVORITES);
        } else {
            cursor.moveToFirst();
            favorites_id = cursor.getLong(0);
            cursor.close();
        }

        String[] cols = new String[] {
            Playlists.Members.AUDIO_ID
        };
        Uri uri = Playlists.Members.getContentUri(EXTERNAL, favorites_id);
        Cursor cur = resolver.query(uri, cols, null, null, null);

        cur.moveToFirst();
        while (!cur.isAfterLast()) {
            if (cur.getLong(0) == id) {
                cur.close();
                return true;
            }
            cur.moveToNext();
        }
        cur.close();
        return false;
    }
    return false;
}
 
开发者ID:liufeiit,项目名称:itmarry,代码行数:48,代码来源:MusicUtils.java


注:本文中的android.provider.MediaStore.Audio.PlaylistsColumns.NAME属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。