ContentResolver in android 2.2 [issue]
Am trying to insert an aduio file in the android phone. the same code works fin in android 2.1
but when i try to use it in Android 2.2; the inserting in ContentResolver succseed but i can't
find my audio file in the gallery (so the user can't see it)
context.sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.parse("file://"+path+filename)));
File k = new File(path, filename);
ContentValues values = new ContentValues();
values.put(MediaStore.Audio.Media.DATA, k.getAbsolutePath());
values.put(MediaStore.Audio.Media.TITLE, aud.TITLE);
values.put(MediaStore.Audio.Media.MIME_TYPE, aud.MIME_TYPE);
values.put(MediaStore.Audio.Media.ARTIST, aud.ARTIST);
values.put(MediaStore.Audio.Media.IS_RINGTONE,开发者_开发技巧 aud.IS_RINGTONE);
values.put(MediaStore.Audio.Media.IS_NOTIFICATION, aud.IS_NOTIFICATION);
values.put(MediaStore.Audio.Media.IS_ALARM, aud.IS_ALARM);
values.put(MediaStore.Audio.Media.IS_MUSIC, aud.IS_MUSIC);
//Insert it into the database
context.getContentResolver().insert(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, values);
Try adding "file:///" that will work
精彩评论