dimanche 24 juillet 2016

android save Ringtone in Sharedprefrences and get it again

I have get the current ringtone . Now I just want to save it in the sharedpreference .

How can I achieve that?

Here the code I tried:

Uri currentRintoneUri = RingtoneManager.getActualDefaultRingtoneUri(context
                                .getApplicationContext(), RingtoneManager.TYPE_RINGTONE);
                        Ringtone currentRingtone = RingtoneManager.getRingtone(context, currentRintoneUri);

It's not working for ringing tone but it works for edittext.

sharedpreferences = getSharedPreferences(MyPRE, Context.MODE_PRIVATE);
                        String current = sharedpreferences.getString(CUR, "");
                                SharedPreferences.Editor editor = sharedpreferences.edit();
                                editor.putString(CUR, String.valueOf((currentRingtone)));
                                editor.commit();

Aucun commentaire:

Enregistrer un commentaire