Create mp3 ringtone from assets folder in Android Programmatically

Before Started:

You must read Create mp3 from res/raw in Android Programmatically

The code is same, only replace get file from res/raw folder to get file from assets folder


I store all mp3 music inside assets/lagu folder


How to do it … ?


Just replace

int idRaw = getBaseContext().getResources().getIdentifier("filename", "raw", getPackageName());
InputStream is = getResources().openRawResource(idRaw);

With this one

InputStream is = getAssets().open("lagu/filename.mp3");

Thanks for reading

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *