예제 #1
0
 /**
  * Create a playlist with the given default playlist name, if no such playlist exists.
  *
  * @param resolver
  * @return Uri
  */
 private Uri createPlaylist(ContentResolver resolver) {
   ContentValues cv = new ContentValues();
   mAudioDBPlaylistName = mContext.getString(R.string.str_db_playlist_name);
   cv.put(MediaStore.Audio.Playlists.NAME, mAudioDBPlaylistName);
   Uri uri = resolver.insert(MediaStore.Audio.Playlists.getContentUri("external"), cv);
   if (uri == null) {
     Log.e(TAG, "---- Unable to save recorded audio -----");
   }
   return uri;
 }
예제 #2
0
 /**
  * Obtain the id for the default play list from the audio_playlists table.
  *
  * @return int
  */
 private int getPlaylistId() {
   Uri uri = MediaStore.Audio.Playlists.getContentUri("external");
   final String[] ids = new String[] {MediaStore.Audio.Playlists._ID};
   final String where = MediaStore.Audio.Playlists.NAME + "=?";
   mAudioDBPlaylistName = mContext.getString(R.string.str_db_playlist_name);
   final String[] args = new String[] {mAudioDBPlaylistName};
   Cursor cursor = query(uri, ids, where, args, null);
   if (cursor == null) {
     Log.v(TAG, "query returns null");
   }
   int id = -1;
   if (cursor != null) {
     cursor.moveToFirst();
     if (!cursor.isAfterLast()) {
       id = cursor.getInt(0);
     }
     cursor.close();
   }
   return id;
 }