<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Android: Saving a sound file to SD from resource and setting as ringtone</title>
	<atom:link href="http://www.stealthcopter.com/blog/2010/01/android-saving-a-sound-file-to-sd-from-resource-and-setting-as-ringtone/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.stealthcopter.com/blog/2010/01/android-saving-a-sound-file-to-sd-from-resource-and-setting-as-ringtone/</link>
	<description>Android, Linux, Python and stealthcopters</description>
	<lastBuildDate>Thu, 09 Feb 2012 16:34:58 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Fernando Boaglio</title>
		<link>http://www.stealthcopter.com/blog/2010/01/android-saving-a-sound-file-to-sd-from-resource-and-setting-as-ringtone/comment-page-2/#comment-6715</link>
		<dc:creator>Fernando Boaglio</dc:creator>
		<pubDate>Wed, 18 Jan 2012 03:22:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.stealthcopter.com/blog/?p=559#comment-6715</guid>
		<description>Excellent post, help me a lot!</description>
		<content:encoded><![CDATA[<p>Excellent post, help me a lot!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tommy</title>
		<link>http://www.stealthcopter.com/blog/2010/01/android-saving-a-sound-file-to-sd-from-resource-and-setting-as-ringtone/comment-page-2/#comment-6632</link>
		<dc:creator>Tommy</dc:creator>
		<pubDate>Wed, 28 Dec 2011 18:07:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.stealthcopter.com/blog/?p=559#comment-6632</guid>
		<description>@mrJ05hua I am encountering the same problem you were and I can not figure it out. After googling I found this site. How did you set up the call of your arrays in the function that saves the file, well chooses the file the save? I know this is old but hey maybe you will reply :) Thanks.</description>
		<content:encoded><![CDATA[<p>@mrJ05hua I am encountering the same problem you were and I can not figure it out. After googling I found this site. How did you set up the call of your arrays in the function that saves the file, well chooses the file the save? I know this is old but hey maybe you will reply <img src='http://www.stealthcopter.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mrj05hua</title>
		<link>http://www.stealthcopter.com/blog/2010/01/android-saving-a-sound-file-to-sd-from-resource-and-setting-as-ringtone/comment-page-2/#comment-6097</link>
		<dc:creator>mrj05hua</dc:creator>
		<pubDate>Fri, 21 Oct 2011 15:39:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.stealthcopter.com/blog/?p=559#comment-6097</guid>
		<description>nevermind lol figured it out thank you so so much!!!!!</description>
		<content:encoded><![CDATA[<p>nevermind lol figured it out thank you so so much!!!!!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mrj05hua</title>
		<link>http://www.stealthcopter.com/blog/2010/01/android-saving-a-sound-file-to-sd-from-resource-and-setting-as-ringtone/comment-page-2/#comment-6089</link>
		<dc:creator>mrj05hua</dc:creator>
		<pubDate>Thu, 20 Oct 2011 11:10:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.stealthcopter.com/blog/?p=559#comment-6089</guid>
		<description>@mat how do you assign an integer to that specific spot of the string or int arrays.  I say a few ways to code it but I keep messing it up.</description>
		<content:encoded><![CDATA[<p>@mat how do you assign an integer to that specific spot of the string or int arrays.  I say a few ways to code it but I keep messing it up.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: satish</title>
		<link>http://www.stealthcopter.com/blog/2010/01/android-saving-a-sound-file-to-sd-from-resource-and-setting-as-ringtone/comment-page-2/#comment-6071</link>
		<dc:creator>satish</dc:creator>
		<pubDate>Tue, 18 Oct 2011 15:34:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.stealthcopter.com/blog/?p=559#comment-6071</guid>
		<description>hi i tried this code. this code doesnt shows any error when i run this program. but it does not set it as a ringtone i dont know y...if save as true i have user the toast. but the toast itslf is not being displayed . pls help me i need this code working becase i need to submit my project</description>
		<content:encoded><![CDATA[<p>hi i tried this code. this code doesnt shows any error when i run this program. but it does not set it as a ringtone i dont know y&#8230;if save as true i have user the toast. but the toast itslf is not being displayed . pls help me i need this code working becase i need to submit my project</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mat</title>
		<link>http://www.stealthcopter.com/blog/2010/01/android-saving-a-sound-file-to-sd-from-resource-and-setting-as-ringtone/comment-page-2/#comment-6070</link>
		<dc:creator>mat</dc:creator>
		<pubDate>Tue, 18 Oct 2011 13:45:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.stealthcopter.com/blog/?p=559#comment-6070</guid>
		<description>Just make a matching string array.

String[] name ={ &quot;Sound 1&quot;, &quot;Sound name 2&quot;, &quot;Chainsaw!&quot;};
int[] sounds = {R.raw.sound1, R.raw.sound2, R.raw.chainsaw};

then just have saveas(0); using the passed integer to correspond to the name and sound in the arrays.</description>
		<content:encoded><![CDATA[<p>Just make a matching string array.</p>
<p>String[] name ={ &#8220;Sound 1&#8243;, &#8220;Sound name 2&#8243;, &#8220;Chainsaw!&#8221;};<br />
int[] sounds = {R.raw.sound1, R.raw.sound2, R.raw.chainsaw};</p>
<p>then just have saveas(0); using the passed integer to correspond to the name and sound in the arrays.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mrj05hua</title>
		<link>http://www.stealthcopter.com/blog/2010/01/android-saving-a-sound-file-to-sd-from-resource-and-setting-as-ringtone/comment-page-2/#comment-6008</link>
		<dc:creator>mrj05hua</dc:creator>
		<pubDate>Sat, 15 Oct 2011 04:09:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.stealthcopter.com/blog/?p=559#comment-6008</guid>
		<description>I have gotten some of the code compiled and changed, I got it to pass an integer to the save as functions, it even saves the number of the resource id. But has some debugging errors, how can i get to use the name.  Or am I going in the wrong direction.

I passed the int as 
int[ ] soundid ={raw files, raw file, raw file};
int j = 0;

then in the button clicks it assigns the int to the corresponding number.  But  in the saveas it saves the resource location IE 2693889.mp3.  How can I change this.</description>
		<content:encoded><![CDATA[<p>I have gotten some of the code compiled and changed, I got it to pass an integer to the save as functions, it even saves the number of the resource id. But has some debugging errors, how can i get to use the name.  Or am I going in the wrong direction.</p>
<p>I passed the int as<br />
int[ ] soundid ={raw files, raw file, raw file};<br />
int j = 0;</p>
<p>then in the button clicks it assigns the int to the corresponding number.  But  in the saveas it saves the resource location IE 2693889.mp3.  How can I change this.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mrj05hua</title>
		<link>http://www.stealthcopter.com/blog/2010/01/android-saving-a-sound-file-to-sd-from-resource-and-setting-as-ringtone/comment-page-2/#comment-6006</link>
		<dc:creator>mrj05hua</dc:creator>
		<pubDate>Sat, 15 Oct 2011 02:16:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.stealthcopter.com/blog/?p=559#comment-6006</guid>
		<description>so i declared them globally as 
int[] soundids = {R.raw.sound1, R.raw.sound2, R.raw.sound3};
that part works but how do i function call into them in the save as or play feature?  Is there a link I missed I will gladly do whatever research you send me too.</description>
		<content:encoded><![CDATA[<p>so i declared them globally as<br />
int[] soundids = {R.raw.sound1, R.raw.sound2, R.raw.sound3};<br />
that part works but how do i function call into them in the save as or play feature?  Is there a link I missed I will gladly do whatever research you send me too.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mrj05hua</title>
		<link>http://www.stealthcopter.com/blog/2010/01/android-saving-a-sound-file-to-sd-from-resource-and-setting-as-ringtone/comment-page-1/#comment-6005</link>
		<dc:creator>mrj05hua</dc:creator>
		<pubDate>Sat, 15 Oct 2011 02:05:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.stealthcopter.com/blog/?p=559#comment-6005</guid>
		<description>Ok but how do i implement that I understand slightly how to declare them globaly but then how do i make the saveas pick from them.  I am stuck at those two parts.  All your help is and will continue to be greatly appreciated.</description>
		<content:encoded><![CDATA[<p>Ok but how do i implement that I understand slightly how to declare them globaly but then how do i make the saveas pick from them.  I am stuck at those two parts.  All your help is and will continue to be greatly appreciated.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mat</title>
		<link>http://www.stealthcopter.com/blog/2010/01/android-saving-a-sound-file-to-sd-from-resource-and-setting-as-ringtone/comment-page-1/#comment-5998</link>
		<dc:creator>mat</dc:creator>
		<pubDate>Fri, 14 Oct 2011 22:18:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.stealthcopter.com/blog/?p=559#comment-5998</guid>
		<description>All your R.raw.chainsaw etc... those are integers.</description>
		<content:encoded><![CDATA[<p>All your R.raw.chainsaw etc&#8230; those are integers.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mrj05hua</title>
		<link>http://www.stealthcopter.com/blog/2010/01/android-saving-a-sound-file-to-sd-from-resource-and-setting-as-ringtone/comment-page-1/#comment-5997</link>
		<dc:creator>mrj05hua</dc:creator>
		<pubDate>Fri, 14 Oct 2011 22:15:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.stealthcopter.com/blog/?p=559#comment-5997</guid>
		<description>I have used your tutorial and its helped me alot, but I have read through each of your posts and I do not understand your using your Raw resources as integers or strings.  I understand you can either put them into arrays as a global variable.  I just don&#039;t know how to do it in java, Everything works great in my app except I need to be able to pass the name of the raw resource to the saveas functions so it will save the file that is pressed.  

MediaPlayer player;
	
&lt;pre name=&quot;code&quot; class=&quot;java&quot;&gt;	
	/** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        
        //Coding for all buttons, registers, and Listeners
        Button btn1 = (Button) findViewById(R.id.btn1);
        registerForContextMenu(btn1); 
        btn1.setOnClickListener(this);
        Button btn2 = (Button) findViewById(R.id.btn2);
        registerForContextMenu(btn2);
        btn2.setOnClickListener(this);
        Button btn3 = (Button) findViewById(R.id.btn3);
        registerForContextMenu(btn3);
        btn3.setOnClickListener(this);
        Button btn4 = (Button) findViewById(R.id.btn4);
        registerForContextMenu(btn4);
        btn4.setOnClickListener(this);
        Button btn5 = (Button) findViewById(R.id.btn5);
        registerForContextMenu(btn5);
        btn5.setOnClickListener(this);
        Button btn6 = (Button) findViewById(R.id.btn6);
        registerForContextMenu(btn6);
        btn6.setOnClickListener(this);
        Button btn7 = (Button) findViewById(R.id.btn7);
        registerForContextMenu(btn7); 
        btn7.setOnClickListener(this);
        Button btn8 = (Button) findViewById(R.id.btn8);
        registerForContextMenu(btn8);
        btn8.setOnClickListener(this);
        Button btn9 = (Button) findViewById(R.id.btn9);
        registerForContextMenu(btn9);
        btn9.setOnClickListener(this);
        
       
        
    }//closes OnCreate
    
    //On click Handlers for multiple buttons 
    public void onClick(View v) {
    	switch(v.getId()){
    	case R.id.btn1:
    		// action to perform on button 1
    		
    		player = MediaPlayer.create(this, R.raw.boomstick);
    		player.start();
    		
    		break;
    	case R.id.btn2:
    		// action to perform on button 1
    		
    		player = MediaPlayer.create(this, R.raw.shebitch);
    		player.start();
    		
    		break;
    	case R.id.btn3:
    		// action to perform on button 1
    		
    		player = MediaPlayer.create(this, R.raw.chainsaw);
    		player.start();
    		
    		break;
    	case R.id.btn4:
    		// action to perform on button 1
    		
    		player = MediaPlayer.create(this, R.raw.boomstick);
    		player.start();
    		
    		break;
    	case R.id.btn5:
    		// action to perform on button 1
    		
    		player = MediaPlayer.create(this, R.raw.shebitch);
    		player.start();
    		
    		break;
    	case R.id.btn6:
    		// action to perform on button 1
    		
    		player = MediaPlayer.create(this, R.raw.chainsaw);
    		player.start();
    		
    		break;
    	case R.id.btn7:
    		// action to perform on button 1
    		
    		player = MediaPlayer.create(this, R.raw.boomstick);
    		player.start();
    		
    		break;
    	case R.id.btn8:
    		// action to perform on button 1
    		
    		player = MediaPlayer.create(this, R.raw.shebitch);
    		player.start();
    		
    		break;
    	case R.id.btn9:
    		// action to perform on button 1
    		
    		player = MediaPlayer.create(this, R.raw.chainsaw);
    		player.start();
    		
    		break;
    	}
    }//closes onClick
    
    @Override
    public void onCreateContextMenu(ContextMenu menu, View v,ContextMenuInfo menuInfo) {
	super.onCreateContextMenu(menu, v, menuInfo);
		menu.setHeaderTitle(&quot;Save As &quot;);
		menu.add(0, v.getId(), 0, &quot;Ringtone&quot;);
		menu.add(0, v.getId(), 0, &quot;Notification&quot;);
		menu.add(0, v.getId(), 0, &quot;Alarm&quot;);
	}//closes onCreateContextMenu

    @Override
	public boolean onContextItemSelected(MenuItem item) {
       	if(item.getTitle()==&quot;Ringtone&quot;){function1(item.getItemId());}
    	else if(item.getTitle()==&quot;Notification&quot;){function2(item.getItemId());}
    	else if(item.getTitle()==&quot;Alarm&quot;){function3(item.getItemId());}
    	else {return false;}
	return true;
	}//Closes MenuItems
    
	public void function1(int id){
		saveasRing(R.raw.shebitch);
    	Toast.makeText(this, &quot;Saved as Ringtone&quot;, Toast.LENGTH_SHORT).show();
    }//Closes Function 1
    public void function2(int id){
    	saveasNotifications(R.raw.shebitch);
    	Toast.makeText(this, &quot;Saved as Notification&quot;, Toast.LENGTH_SHORT).show();
    }//closes Function 2
    public void function3(int id){
    	saveasAlarm(R.raw.shebitch);
    	Toast.makeText(this, &quot;Saved as Alarm&quot;, Toast.LENGTH_SHORT).show();
    }//Closes Function 3
    
    //Save as Ringtone Coding for Function 3
    public boolean saveasRing(int ressound){
    	 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=&quot;/sdcard/media/audio/ringtones/&quot;;
    	 String filename= &quot;shebitch&quot; +&quot;.mp3&quot;;

    	 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;
    	 }    

    	 sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.parse(&quot;file://&quot;+path+filename)));

    	 File k = new File(path, filename);

    	 ContentValues values = new ContentValues();
    	 values.put(MediaStore.MediaColumns.DATA, k.getAbsolutePath());
    	 values.put(MediaStore.MediaColumns.TITLE, &quot;exampletitle&quot;);
    	 values.put(MediaStore.MediaColumns.MIME_TYPE, &quot;audio/mp3&quot;);
    	 values.put(MediaStore.Audio.Media.ARTIST, &quot;cssounds &quot;);
    	 values.put(MediaStore.Audio.Media.IS_RINGTONE, true);
    	 values.put(MediaStore.Audio.Media.IS_NOTIFICATION, false);
    	 values.put(MediaStore.Audio.Media.IS_ALARM, false);
    	 values.put(MediaStore.Audio.Media.IS_MUSIC, false);

    	 //Insert it into the database
    	 this.getContentResolver().insert(MediaStore.Audio.Media.getContentUriForPath(k.getAbsolutePath()), values);


    	 return true;	
    }//Closes Save as Ringtone 
&lt;/pre&gt;
  
Where or how do I set up the function call for it to have the int and then check for the saveas filename and change the name upon which file is playing</description>
		<content:encoded><![CDATA[<p>I have used your tutorial and its helped me alot, but I have read through each of your posts and I do not understand your using your Raw resources as integers or strings.  I understand you can either put them into arrays as a global variable.  I just don&#8217;t know how to do it in java, Everything works great in my app except I need to be able to pass the name of the raw resource to the saveas functions so it will save the file that is pressed.  </p>
<p>MediaPlayer player;</p>
<pre name="code" class="java">
	/** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        //Coding for all buttons, registers, and Listeners
        Button btn1 = (Button) findViewById(R.id.btn1);
        registerForContextMenu(btn1);
        btn1.setOnClickListener(this);
        Button btn2 = (Button) findViewById(R.id.btn2);
        registerForContextMenu(btn2);
        btn2.setOnClickListener(this);
        Button btn3 = (Button) findViewById(R.id.btn3);
        registerForContextMenu(btn3);
        btn3.setOnClickListener(this);
        Button btn4 = (Button) findViewById(R.id.btn4);
        registerForContextMenu(btn4);
        btn4.setOnClickListener(this);
        Button btn5 = (Button) findViewById(R.id.btn5);
        registerForContextMenu(btn5);
        btn5.setOnClickListener(this);
        Button btn6 = (Button) findViewById(R.id.btn6);
        registerForContextMenu(btn6);
        btn6.setOnClickListener(this);
        Button btn7 = (Button) findViewById(R.id.btn7);
        registerForContextMenu(btn7);
        btn7.setOnClickListener(this);
        Button btn8 = (Button) findViewById(R.id.btn8);
        registerForContextMenu(btn8);
        btn8.setOnClickListener(this);
        Button btn9 = (Button) findViewById(R.id.btn9);
        registerForContextMenu(btn9);
        btn9.setOnClickListener(this);

    }//closes OnCreate

    //On click Handlers for multiple buttons
    public void onClick(View v) {
    	switch(v.getId()){
    	case R.id.btn1:
    		// action to perform on button 1

    		player = MediaPlayer.create(this, R.raw.boomstick);
    		player.start();

    		break;
    	case R.id.btn2:
    		// action to perform on button 1

    		player = MediaPlayer.create(this, R.raw.shebitch);
    		player.start();

    		break;
    	case R.id.btn3:
    		// action to perform on button 1

    		player = MediaPlayer.create(this, R.raw.chainsaw);
    		player.start();

    		break;
    	case R.id.btn4:
    		// action to perform on button 1

    		player = MediaPlayer.create(this, R.raw.boomstick);
    		player.start();

    		break;
    	case R.id.btn5:
    		// action to perform on button 1

    		player = MediaPlayer.create(this, R.raw.shebitch);
    		player.start();

    		break;
    	case R.id.btn6:
    		// action to perform on button 1

    		player = MediaPlayer.create(this, R.raw.chainsaw);
    		player.start();

    		break;
    	case R.id.btn7:
    		// action to perform on button 1

    		player = MediaPlayer.create(this, R.raw.boomstick);
    		player.start();

    		break;
    	case R.id.btn8:
    		// action to perform on button 1

    		player = MediaPlayer.create(this, R.raw.shebitch);
    		player.start();

    		break;
    	case R.id.btn9:
    		// action to perform on button 1

    		player = MediaPlayer.create(this, R.raw.chainsaw);
    		player.start();

    		break;
    	}
    }//closes onClick

    @Override
    public void onCreateContextMenu(ContextMenu menu, View v,ContextMenuInfo menuInfo) {
	super.onCreateContextMenu(menu, v, menuInfo);
		menu.setHeaderTitle("Save As ");
		menu.add(0, v.getId(), 0, "Ringtone");
		menu.add(0, v.getId(), 0, "Notification");
		menu.add(0, v.getId(), 0, "Alarm");
	}//closes onCreateContextMenu

    @Override
	public boolean onContextItemSelected(MenuItem item) {
       	if(item.getTitle()=="Ringtone"){function1(item.getItemId());}
    	else if(item.getTitle()=="Notification"){function2(item.getItemId());}
    	else if(item.getTitle()=="Alarm"){function3(item.getItemId());}
    	else {return false;}
	return true;
	}//Closes MenuItems

	public void function1(int id){
		saveasRing(R.raw.shebitch);
    	Toast.makeText(this, "Saved as Ringtone", Toast.LENGTH_SHORT).show();
    }//Closes Function 1
    public void function2(int id){
    	saveasNotifications(R.raw.shebitch);
    	Toast.makeText(this, "Saved as Notification", Toast.LENGTH_SHORT).show();
    }//closes Function 2
    public void function3(int id){
    	saveasAlarm(R.raw.shebitch);
    	Toast.makeText(this, "Saved as Alarm", Toast.LENGTH_SHORT).show();
    }//Closes Function 3

    //Save as Ringtone Coding for Function 3
    public boolean saveasRing(int ressound){
    	 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= "shebitch" +".mp3";

    	 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;
    	 }    

    	 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.MediaColumns.DATA, k.getAbsolutePath());
    	 values.put(MediaStore.MediaColumns.TITLE, "exampletitle");
    	 values.put(MediaStore.MediaColumns.MIME_TYPE, "audio/mp3");
    	 values.put(MediaStore.Audio.Media.ARTIST, "cssounds ");
    	 values.put(MediaStore.Audio.Media.IS_RINGTONE, true);
    	 values.put(MediaStore.Audio.Media.IS_NOTIFICATION, false);
    	 values.put(MediaStore.Audio.Media.IS_ALARM, false);
    	 values.put(MediaStore.Audio.Media.IS_MUSIC, false);

    	 //Insert it into the database
    	 this.getContentResolver().insert(MediaStore.Audio.Media.getContentUriForPath(k.getAbsolutePath()), values);

    	 return true;
    }//Closes Save as Ringtone
</pre>
<p>Where or how do I set up the function call for it to have the int and then check for the saveas filename and change the name upon which file is playing</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: waseem sarwar</title>
		<link>http://www.stealthcopter.com/blog/2010/01/android-saving-a-sound-file-to-sd-from-resource-and-setting-as-ringtone/comment-page-1/#comment-5967</link>
		<dc:creator>waseem sarwar</dc:creator>
		<pubDate>Mon, 10 Oct 2011 17:41:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.stealthcopter.com/blog/?p=559#comment-5967</guid>
		<description>Great tutorial i get the idea from here to write .svg file from resource to sdcard</description>
		<content:encoded><![CDATA[<p>Great tutorial i get the idea from here to write .svg file from resource to sdcard</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul</title>
		<link>http://www.stealthcopter.com/blog/2010/01/android-saving-a-sound-file-to-sd-from-resource-and-setting-as-ringtone/comment-page-1/#comment-5924</link>
		<dc:creator>Paul</dc:creator>
		<pubDate>Mon, 03 Oct 2011 19:50:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.stealthcopter.com/blog/?p=559#comment-5924</guid>
		<description>Great example!! Has helped massively and very easy to follow. I was just wondering how you save multiple sounds? I have a soundboard with 18 sounds and would like to be able to save each sound separately. Many thanks.</description>
		<content:encoded><![CDATA[<p>Great example!! Has helped massively and very easy to follow. I was just wondering how you save multiple sounds? I have a soundboard with 18 sounds and would like to be able to save each sound separately. Many thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mat</title>
		<link>http://www.stealthcopter.com/blog/2010/01/android-saving-a-sound-file-to-sd-from-resource-and-setting-as-ringtone/comment-page-1/#comment-5685</link>
		<dc:creator>mat</dc:creator>
		<pubDate>Sun, 28 Aug 2011 14:31:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.stealthcopter.com/blog/?p=559#comment-5685</guid>
		<description>Will, in my example the &quot;this&quot; is outside of any subclasses and so refers to my main class/activity you can replace this with the name of your class (the name of your java file).</description>
		<content:encoded><![CDATA[<p>Will, in my example the &#8220;this&#8221; is outside of any subclasses and so refers to my main class/activity you can replace this with the name of your class (the name of your java file).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Wil</title>
		<link>http://www.stealthcopter.com/blog/2010/01/android-saving-a-sound-file-to-sd-from-resource-and-setting-as-ringtone/comment-page-1/#comment-5682</link>
		<dc:creator>Wil</dc:creator>
		<pubDate>Sat, 27 Aug 2011 20:13:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.stealthcopter.com/blog/?p=559#comment-5682</guid>
		<description>I keep getting the following error: The method getContentResolver() is undefined for the type new View.OnClickListener(){}

Can you please help me with solving this issue please.</description>
		<content:encoded><![CDATA[<p>I keep getting the following error: The method getContentResolver() is undefined for the type new View.OnClickListener(){}</p>
<p>Can you please help me with solving this issue please.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tim</title>
		<link>http://www.stealthcopter.com/blog/2010/01/android-saving-a-sound-file-to-sd-from-resource-and-setting-as-ringtone/comment-page-1/#comment-5209</link>
		<dc:creator>Tim</dc:creator>
		<pubDate>Mon, 27 Jun 2011 02:40:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.stealthcopter.com/blog/?p=559#comment-5209</guid>
		<description>Any chance I can still get help with this.  My soundboard works great on one button, but my second will not work.</description>
		<content:encoded><![CDATA[<p>Any chance I can still get help with this.  My soundboard works great on one button, but my second will not work.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Prototype</title>
		<link>http://www.stealthcopter.com/blog/2010/01/android-saving-a-sound-file-to-sd-from-resource-and-setting-as-ringtone/comment-page-1/#comment-4945</link>
		<dc:creator>Prototype</dc:creator>
		<pubDate>Sun, 01 May 2011 23:57:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.stealthcopter.com/blog/?p=559#comment-4945</guid>
		<description>I have this:
public class ProvaNotifica extends Activity {
    
	Button button1;
	MediaPlayer mp=null;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        button1 = (Button)this.findViewById(R.id.button1);
        
        button1.setOnClickListener(new OnClickListener(){

			public void onClick(View v) {
				
				if(mp!=null){
					mp.release();
					
				}
				mp = MediaPlayer.create(getBaseContext(), R.raw.burp);
				mp.start();
				mp.setOnCompletionListener(new OnCompletionListener() {

                    public void onCompletion(MediaPlayer mp) {
                        mp.release();
                    }

                });
			}
			
        });
        
        button1.setOnLongClickListener(new View.OnLongClickListener() {
        	public boolean onLongClick(View view) {
        		Boolean bool = saveas(R.raw.burp);
        		if(bool){
        			Toast.makeText(getBaseContext(), &quot;Setted as ringtone&quot;, 2).show();
        		}else{
        			Toast.makeText(getBaseContext(), &quot;Error&quot;, 2).show();
        		}
				return true;
        	}
        });
        
    }
    
    public boolean saveas(int ressound){  
    	   	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) { 
    	   		Toast.makeText(getBaseContext(), &quot;Errore1&quot;, 2).show();
    		   	return false;  
    	   	}  
    	   	String path = &quot;/sdcard/media/audio/ringtones/&quot;;  
    	   	String filename = &quot;burpfile&quot;+&quot;.ogg&quot;;  
    	   
    	   	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) {  
    	  		Toast.makeText(getBaseContext(), &quot;Error 2&quot;, 2).show();
    	  		return false;  
    	  	} catch (IOException e) {
    	  		Toast.makeText(getBaseContext(), &quot;Error 3&quot;, 2).show();
    	  		return false;  
    	  	}        
    	  	sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.parse(&quot;file://&quot;+path+filename)));  
    	  	File k = new File(path, filename);  
    	  	ContentValues values = new ContentValues();  
    	  	values.put(MediaStore.MediaColumns.DATA, k.getAbsolutePath());  
    	  	values.put(MediaStore.MediaColumns.TITLE, &quot;simpson&quot;);  
    	  	values.put(MediaStore.MediaColumns.MIME_TYPE, &quot;audio/ogg&quot;);  
    	  	values.put(MediaStore.Audio.Media.ARTIST, &quot;ciao&quot;);  
    	  	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);  
    	  	//Insert it into the database  
    	  	this.getContentResolver().insert(MediaStore.Audio.Media.getContentUriForPath(k.getAbsolutePath()), values);  
    	 	
    	  	return true;  
    	}  
}


but it always show me the toast with the message Error 2 that corrisponds to the FileNotFoundException
can anybody help?</description>
		<content:encoded><![CDATA[<p>I have this:<br />
public class ProvaNotifica extends Activity {</p>
<p>	Button button1;<br />
	MediaPlayer mp=null;<br />
    @Override<br />
    public void onCreate(Bundle savedInstanceState) {<br />
        super.onCreate(savedInstanceState);<br />
        setContentView(R.layout.main);</p>
<p>        button1 = (Button)this.findViewById(R.id.button1);</p>
<p>        button1.setOnClickListener(new OnClickListener(){</p>
<p>			public void onClick(View v) {</p>
<p>				if(mp!=null){<br />
					mp.release();</p>
<p>				}<br />
				mp = MediaPlayer.create(getBaseContext(), R.raw.burp);<br />
				mp.start();<br />
				mp.setOnCompletionListener(new OnCompletionListener() {</p>
<p>                    public void onCompletion(MediaPlayer mp) {<br />
                        mp.release();<br />
                    }</p>
<p>                });<br />
			}</p>
<p>        });</p>
<p>        button1.setOnLongClickListener(new View.OnLongClickListener() {<br />
        	public boolean onLongClick(View view) {<br />
        		Boolean bool = saveas(R.raw.burp);<br />
        		if(bool){<br />
        			Toast.makeText(getBaseContext(), &#8220;Setted as ringtone&#8221;, 2).show();<br />
        		}else{<br />
        			Toast.makeText(getBaseContext(), &#8220;Error&#8221;, 2).show();<br />
        		}<br />
				return true;<br />
        	}<br />
        });</p>
<p>    }</p>
<p>    public boolean saveas(int ressound){<br />
    	   	byte[] buffer=null;<br />
    	   	InputStream fIn = getBaseContext().getResources().openRawResource(ressound);<br />
    	   	int size=0;  </p>
<p>    	   	try {<br />
    		   	size = fIn.available();<br />
    		   	buffer = new byte[size];<br />
    		   	fIn.read(buffer);<br />
    		   	fIn.close();<br />
    	   	}catch (IOException e) {<br />
    	   		Toast.makeText(getBaseContext(), &#8220;Errore1&#8243;, 2).show();<br />
    		   	return false;<br />
    	   	}<br />
    	   	String path = &#8220;/sdcard/media/audio/ringtones/&#8221;;<br />
    	   	String filename = &#8220;burpfile&#8221;+&#8221;.ogg&#8221;;  </p>
<p>    	   	boolean exists = (new File(path)).exists();<br />
    	   	if (!exists){<br />
    	   		new File(path).mkdirs();<br />
    	   	}<br />
    	   	FileOutputStream save;<br />
    	   	try {<br />
    	   		save = new FileOutputStream(path+filename);<br />
    	   		save.write(buffer);<br />
    	   		save.flush();<br />
    	   		save.close();<br />
    	  	} catch (FileNotFoundException e) {<br />
    	  		Toast.makeText(getBaseContext(), &#8220;Error 2&#8243;, 2).show();<br />
    	  		return false;<br />
    	  	} catch (IOException e) {<br />
    	  		Toast.makeText(getBaseContext(), &#8220;Error 3&#8243;, 2).show();<br />
    	  		return false;<br />
    	  	}<br />
    	  	sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.parse(&#8220;file://&#8221;+path+filename)));<br />
    	  	File k = new File(path, filename);<br />
    	  	ContentValues values = new ContentValues();<br />
    	  	values.put(MediaStore.MediaColumns.DATA, k.getAbsolutePath());<br />
    	  	values.put(MediaStore.MediaColumns.TITLE, &#8220;simpson&#8221;);<br />
    	  	values.put(MediaStore.MediaColumns.MIME_TYPE, &#8220;audio/ogg&#8221;);<br />
    	  	values.put(MediaStore.Audio.Media.ARTIST, &#8220;ciao&#8221;);<br />
    	  	values.put(MediaStore.Audio.Media.IS_RINGTONE, true);<br />
    	  	values.put(MediaStore.Audio.Media.IS_NOTIFICATION, true);<br />
    	  	values.put(MediaStore.Audio.Media.IS_ALARM, true);<br />
    	  	values.put(MediaStore.Audio.Media.IS_MUSIC, false);<br />
    	  	//Insert it into the database<br />
    	  	this.getContentResolver().insert(MediaStore.Audio.Media.getContentUriForPath(k.getAbsolutePath()), values);  </p>
<p>    	  	return true;<br />
    	}<br />
}</p>
<p>but it always show me the toast with the message Error 2 that corrisponds to the FileNotFoundException<br />
can anybody help?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris</title>
		<link>http://www.stealthcopter.com/blog/2010/01/android-saving-a-sound-file-to-sd-from-resource-and-setting-as-ringtone/comment-page-1/#comment-4889</link>
		<dc:creator>Chris</dc:creator>
		<pubDate>Sat, 16 Apr 2011 04:27:47 +0000</pubDate>
		<guid isPermaLink="false">http://www.stealthcopter.com/blog/?p=559#comment-4889</guid>
		<description>I keep getting this error

The method insert(Uri, ContentValues) is undefined for the type Object</description>
		<content:encoded><![CDATA[<p>I keep getting this error</p>
<p>The method insert(Uri, ContentValues) is undefined for the type Object</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: vamp6x6x6x</title>
		<link>http://www.stealthcopter.com/blog/2010/01/android-saving-a-sound-file-to-sd-from-resource-and-setting-as-ringtone/comment-page-1/#comment-4702</link>
		<dc:creator>vamp6x6x6x</dc:creator>
		<pubDate>Tue, 08 Feb 2011 14:09:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.stealthcopter.com/blog/?p=559#comment-4702</guid>
		<description>@mat sorry for the trouble but could you give me like an example or something because see I learned half of what I know from youtube videos because I learn better by showing...and as far as I know there isn&#039;t this situation on youtube.</description>
		<content:encoded><![CDATA[<p>@mat sorry for the trouble but could you give me like an example or something because see I learned half of what I know from youtube videos because I learn better by showing&#8230;and as far as I know there isn&#8217;t this situation on youtube.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mat</title>
		<link>http://www.stealthcopter.com/blog/2010/01/android-saving-a-sound-file-to-sd-from-resource-and-setting-as-ringtone/comment-page-1/#comment-4701</link>
		<dc:creator>mat</dc:creator>
		<pubDate>Tue, 08 Feb 2011 13:44:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.stealthcopter.com/blog/?p=559#comment-4701</guid>
		<description>@vamp6x6x6x to call a function you write the function name... perhaps you should go over a bit of basic java first?</description>
		<content:encoded><![CDATA[<p>@vamp6x6x6x to call a function you write the function name&#8230; perhaps you should go over a bit of basic java first?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: vamp6x6x6x</title>
		<link>http://www.stealthcopter.com/blog/2010/01/android-saving-a-sound-file-to-sd-from-resource-and-setting-as-ringtone/comment-page-1/#comment-4699</link>
		<dc:creator>vamp6x6x6x</dc:creator>
		<pubDate>Tue, 08 Feb 2011 02:03:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.stealthcopter.com/blog/?p=559#comment-4699</guid>
		<description>@mat How do I call my save function in the toast and what should my buffer size be?</description>
		<content:encoded><![CDATA[<p>@mat How do I call my save function in the toast and what should my buffer size be?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mat</title>
		<link>http://www.stealthcopter.com/blog/2010/01/android-saving-a-sound-file-to-sd-from-resource-and-setting-as-ringtone/comment-page-1/#comment-4688</link>
		<dc:creator>mat</dc:creator>
		<pubDate>Thu, 03 Feb 2011 23:56:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.stealthcopter.com/blog/?p=559#comment-4688</guid>
		<description>@vamp6x6x6x as I said above, you never call your save function. Also looks like you&#039;ve added size=0 in which will cause pain. You could never write a file using an empty buffer.</description>
		<content:encoded><![CDATA[<p>@vamp6x6x6x as I said above, you never call your save function. Also looks like you&#8217;ve added size=0 in which will cause pain. You could never write a file using an empty buffer.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: vamp6x6x6x</title>
		<link>http://www.stealthcopter.com/blog/2010/01/android-saving-a-sound-file-to-sd-from-resource-and-setting-as-ringtone/comment-page-1/#comment-4687</link>
		<dc:creator>vamp6x6x6x</dc:creator>
		<pubDate>Thu, 03 Feb 2011 23:34:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.stealthcopter.com/blog/?p=559#comment-4687</guid>
		<description>@mat toast messages do work 100% for me I just need to find a way to make it so it actually saves the ringtone.</description>
		<content:encoded><![CDATA[<p>@mat toast messages do work 100% for me I just need to find a way to make it so it actually saves the ringtone.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mat</title>
		<link>http://www.stealthcopter.com/blog/2010/01/android-saving-a-sound-file-to-sd-from-resource-and-setting-as-ringtone/comment-page-1/#comment-4681</link>
		<dc:creator>mat</dc:creator>
		<pubDate>Thu, 03 Feb 2011 08:27:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.stealthcopter.com/blog/?p=559#comment-4681</guid>
		<description>@vamp6x6x6x You never call your saveas function but the toast messages should appear when you press the context menu items.</description>
		<content:encoded><![CDATA[<p>@vamp6x6x6x You never call your saveas function but the toast messages should appear when you press the context menu items.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: vamp6x6x6x</title>
		<link>http://www.stealthcopter.com/blog/2010/01/android-saving-a-sound-file-to-sd-from-resource-and-setting-as-ringtone/comment-page-1/#comment-4676</link>
		<dc:creator>vamp6x6x6x</dc:creator>
		<pubDate>Wed, 02 Feb 2011 19:09:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.stealthcopter.com/blog/?p=559#comment-4676</guid>
		<description>I need your help I tried to add the following code to my button and nothing:


&lt;pre name=&quot;code&quot; class=&quot;java&quot;&gt;
public class MyMain extends Activity {
    /** Called when the activity is first created. */
	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        Button btn = (Button) findViewById(R.id.Button01);
        registerForContextMenu(btn);
    }

    @Override
    public void onCreateContextMenu(ContextMenu menu, View v,ContextMenuInfo menuInfo) {
        super.onCreateContextMenu(menu, v, menuInfo);
                menu.setHeaderTitle(&quot;Context Menu&quot;);
                menu.add(0, v.getId(), 0, &quot;Action 1&quot;);
                menu.add(0, v.getId(), 0, &quot;Action 2&quot;);
        }

    @Override
        public boolean onContextItemSelected(MenuItem item) {
        if(item.getTitle()==&quot;Action 1&quot;){function1(item.getItemId());}
        else if(item.getTitle()==&quot;Action 2&quot;){function2(item.getItemId());}
        else {return false;}
        return true;
        }

    public void function1(int id){
        Toast.makeText(this, &quot;function 1 called&quot;, Toast.LENGTH_SHORT).show();
    }
    public void function2(int id){
        Toast.makeText(this, &quot;function 2 called&quot;, Toast.LENGTH_SHORT).show();
    }
    
    public boolean saveas(int ressound){
    	 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=&quot;/sdcard/media/audio/ringtones/&quot;;
    	 
    	 String filename=&quot;money&quot;+&quot;.ogg&quot;;

    	 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;
    	 }    

    	 sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.parse(&quot;file://&quot;+path+filename)));

    	 File k = new File(path, filename);

    	 ContentValues values = new ContentValues();
    	 values.put(MediaStore.MediaColumns.DATA, k.getAbsolutePath());
    	 values.put(MediaStore.MediaColumns.TITLE, &quot;exampletitle&quot;);
    	 values.put(MediaStore.MediaColumns.MIME_TYPE, &quot;audio/ogg&quot;);
    	 values.put(MediaStore.Audio.Media.ARTIST, &quot;cssounds &quot;);
    	 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);

    	 //Insert it into the database
    	 this.getContentResolver().insert(MediaStore.Audio.Media.getContentUriForPath(k.getAbsolutePath()), values);

    	 return true;
    	}
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>I need your help I tried to add the following code to my button and nothing:</p>
<pre name="code" class="java">
public class MyMain extends Activity {
    /** Called when the activity is first created. */
	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        Button btn = (Button) findViewById(R.id.Button01);
        registerForContextMenu(btn);
    }

    @Override
    public void onCreateContextMenu(ContextMenu menu, View v,ContextMenuInfo menuInfo) {
        super.onCreateContextMenu(menu, v, menuInfo);
                menu.setHeaderTitle("Context Menu");
                menu.add(0, v.getId(), 0, "Action 1");
                menu.add(0, v.getId(), 0, "Action 2");
        }

    @Override
        public boolean onContextItemSelected(MenuItem item) {
        if(item.getTitle()=="Action 1"){function1(item.getItemId());}
        else if(item.getTitle()=="Action 2"){function2(item.getItemId());}
        else {return false;}
        return true;
        }

    public void function1(int id){
        Toast.makeText(this, "function 1 called", Toast.LENGTH_SHORT).show();
    }
    public void function2(int id){
        Toast.makeText(this, "function 2 called", Toast.LENGTH_SHORT).show();
    }

    public boolean saveas(int ressound){
    	 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="money"+".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;
    	 }    

    	 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.MediaColumns.DATA, k.getAbsolutePath());
    	 values.put(MediaStore.MediaColumns.TITLE, "exampletitle");
    	 values.put(MediaStore.MediaColumns.MIME_TYPE, "audio/ogg");
    	 values.put(MediaStore.Audio.Media.ARTIST, "cssounds ");
    	 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);

    	 //Insert it into the database
    	 this.getContentResolver().insert(MediaStore.Audio.Media.getContentUriForPath(k.getAbsolutePath()), values);

    	 return true;
    	}
</pre>
]]></content:encoded>
	</item>
</channel>
</rss>

