title: Using Intents to pass data for ringtones
body: <p>So far I've been making applications with set as Ringtone feature by creating 1 activity for 1 file. It was bad because with apps with more than 20 ringtones I would've needed 20 activities which would affect app size and performance. Then I found that there is a way to do that with only 1 activity and layout, passing data with Intents. Now I have pretty good idea how that works except one thing that bothers me. That is how do I define strings.
  I need 1 string for name and 1 for file path</p>
  
  <p>My code:</p>
  
  <pre><code>Boolean success = false;
                      rsound = new File(rpath, "Slow tone.mp3");rpath.mkdirs(); //Copied file name
                      if (!rsound.exists()) {
  
  
  
  
                          try {
                              InputStream in = getResources().openRawResource(R.raw.s8slowtone); //path for file 
                              FileOutputStream out = new FileOutputStream(rsound.getPath());
                              byte[] buff = new byte[1024];
                              int read = 0;
  
                              try {
                                  while ((read = in.read(buff)) &gt; 0) {
                                      out.write(buff, 0, read);
                                  }
                              } finally {
                                  in.close();
  
                                  out.close();
                              }
                          } catch (Exception e) {
                              success = false;
  
                          }
                      } else {
                          success = true;
                          setRingtone();
  
                      }
  
                      if (!success) { 
                         setRingtone();
  
  
                      }
                  }
  
                  private void setRingtone() {
                      ContentValues values = new ContentValues();
                         values.put(MediaStore.MediaColumns.DATA, rsound.getAbsolutePath());
                         values.put(MediaStore.MediaColumns.TITLE, "Slow tone"); //Ringtone name
                         values.put(MediaStore.MediaColumns.MIME_TYPE, "audio/*");
                         values.put(MediaStore.Audio.Media.ARTIST, " ");
                         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, true);
  
                         Uri uri = MediaStore.Audio.Media.getContentUriForPath(rsound.getAbsolutePath());
                         getContentResolver().delete(uri, MediaStore.MediaColumns.DATA + "=\"" + rsound.getAbsolutePath() + "\"",
                                 null);
                         Uri newUri = getContentResolver().insert(uri, values);
  
                         RingtoneManager.setActualDefaultRingtoneUri(
                                 S15.this, RingtoneManager.TYPE_RINGTONE,
                                 newUri);
                         Toast.makeText(getApplicationContext(), "Ringtone set successfully",
                                 Toast.LENGTH_SHORT).show();
  </code></pre>
  
  <p>So How do I do this? How do I define string for each file and how to pass them?</p>
  
  <p>Since question is unclear for some members I will make it simpler
  I don't have idea how should I write strings so when I start RingtoneManager Activity using Intent, I pass data from strings.
  So How should I write my code to pass this</p>
  
  <p>File name "Slow tone.mp3"</p>
  
  <p>File path: R.raw.s8slowtone)</p>
  
  <p>Ringtone name "Slow tone"</p>