android铃声-如何添加从URL路径获取的铃声

android铃声-如何添加从URL路径获取的铃声,android,Android,我想知道,当用户在活动中长时间单击铃声名称时,是否有任何方法可以设置从url路径获取的铃声 下面的代码我试图将filnal路径从R.raw.sound1更改为URL路径,但仍然不能 任何人都可以给我一个线索,如何设置铃声从URL获取文件 这是我的密码 final MediaPlayer ring01 = MediaPlayer.create(this, R.raw.sound1); // play sound files on clicks Button s01 = (Button)

我想知道,当用户在活动中长时间单击铃声名称时,是否有任何方法可以设置从url路径获取的铃声

下面的代码我试图将filnal路径从R.raw.sound1更改为URL路径,但仍然不能

任何人都可以给我一个线索,如何设置铃声从URL获取文件

这是我的密码
final MediaPlayer ring01 = MediaPlayer.create(this, R.raw.sound1);

// play sound files on clicks
    Button s01 = (Button) findViewById(R.id.btnring01); 
    s01.setText(this.getString(R.string.title01));
    s01.setOnClickListener(new OnClickListener()
    {
        public void onClick(View v)
        {
    try 
            {
        ring01.prepare();
    }
            catch (IllegalStateException e)
            {
        e.printStackTrace();
    } 
            catch (IOException e)
            {
        e.printStackTrace();
        }
    ring01.start();             
    }
});
    registerForContextMenu(s01);

public void onCreateContextMenu(ContextMenu menu, View v,ContextMenuInfo menuInfo) {  
super.onCreateContextMenu(menu, v, menuInfo);  
        menu.setHeaderTitle("Save as...");  
        menu.add(0, v.getId(), 0, "Tab Here To Save As Ringtone");    
    }  

@Override  
public boolean onContextItemSelected(MenuItem item) {  
    if(item.getTitle()=="Tab Here To Save As Ringtone"){function1(item.getItemId());}  
    else {return false;}  
return true;  
}

public boolean function1(int ressound){

    String soundname = "";

    switch(ressound)
    {
        case R.id.btnring01:
        ressound=R.raw.aftermath;
        soundname = (this.getString(R.string.title01));
        break;
    }

  //and so on and so on.....
  byte[] buffer=null;
   InputStream fIn = getBaseContext().getResources().openRawResource(ressound);
   int size=0;

   try {
   size = fIn.available();
   buffer = new byte[size];
   fIn.read(buffer);
   fIn.close();
   } catch (IOException e) {
   // TODO Auto-generated catch block
   return false;
   }

   String path="/sdcard/media/audio/ringtones/";
   String filename=soundname+".ogg";

   boolean exists = (new File(path)).exists();
   if (!exists){new File(path).mkdirs();}

   FileOutputStream save;
   try {
   save = new FileOutputStream(path+filename);
   save.write(buffer);
   save.flush();
   save.close();
   } catch (FileNotFoundException e) {
   // TODO Auto-generated catch block
   return false;
   } catch (IOException e) {
   // TODO Auto-generated catch block
   return false;
   }
 File k = new File(path, filename);

   ContentValues values = new ContentValues();
   values.put(MediaStore.MediaColumns.DATA, k.getAbsolutePath());
   values.put(MediaStore.MediaColumns.TITLE, soundname);
   values.put(MediaStore.MediaColumns.SIZE, 215454);
   values.put(MediaStore.MediaColumns.MIME_TYPE, "audio/ogg");
   values.put(MediaStore.Audio.Media.ARTIST, "Sokun Kanha");
   values.put(MediaStore.Audio.Media.DURATION, 230);
   values.put(MediaStore.Audio.Media.IS_RINGTONE, true);
   //values.put(MediaStore.Audio.Media.IS_RINGTONE, true);
   //values.put(MediaStore.Audio.Media.IS_NOTIFICATION, true);
   //values.put(MediaStore.Audio.Media.IS_ALARM, true);
   //values.put(MediaStore.Audio.Media.IS_MUSIC, false);
   values.put(MediaStore.Audio.Media.IS_NOTIFICATION, false);
   values.put(MediaStore.Audio.Media.IS_ALARM, false);
   values.put(MediaStore.Audio.Media.IS_MUSIC, false);