将录音文件上传到媒体苦以及给特殊联系人一个铃声

protected void processaudiofile() 
{
   ContentValues values = new ContentValues(3);
   long current = System.currentTimeMillis();
   values.put(MediaStore.Audio.Media.TITLE, "audio" + audiofile.getName());
   values.put(MediaStore.Audio.Media.DATE_ADDED, (int) (current / 1000));
   values.put(MediaStore.Audio.Media.MIME_TYPE, "audio/3gpp");
   values.put(MediaStore.Audio.Media.DATA, audiofile.getAbsolutePath());
   ContentResolver contentResolver = getContentResolver();
   
   Uri base = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
   Uri newUri = contentResolver.insert(base, values);
   
   sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, newUri));
}

 2.Uri contactUri; 
ContentValues values = new ContentValues(); 
values
.put(ContactsContract.Contacts.CUSTOM_RINGTONE,  
    newRingtoneUri
.toString()); 
context
.getContentResolver().update(contactUri, values, where, args ); 

你可能感兴趣的:(文件上传)