I already have the right things to play audio files from RAW, and fool around with it but, here is what I want to do: I want to enable the user to select audio from sdcard. and choose that so the app play it for him. I have :
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"></uses-permission>
then in preferences: I have:
<Preference
android:title="Pick file"
android:key="filePicker" />
and then in ShowPreferenceActivity I have:
Preference filePicker = (Preference) findPreference("filePicker");
filePicker.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
//Intent intent = new Intent("org.openintents.action.PICK_FILE"); //Intent to start openIntents File Manager
//startActivityForResult(intent, 1);
Log.v("filePicker:", "filePicker got CLICKED");
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("Audio/mp3");
startActivityForResult(intent, 1);
return true;
and also:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
//get the new value from Intent data
String newValue = "";
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
SharedPreferences.Editor editor = preferences.edit();
editor.putString("filePicker", newValue);
Log.v("filePicker:RESULT:", newValue);
editor.commit();
Im sure the problem lays here, because the log.v never gets called. so wherever I try:
SharedPreferences sharedPrefs = PreferenceManager
.getDefaultSharedPreferences(this);
String changedRINGTONE=sharedPrefs.getString("filepicker", "NULL");
changedRINGTONE
is null. and not the NULL (with the uppercase) I passed in getString, as it is really null!
pardon my novice information, any guide is highly appreciated.