You can make your toast more general:
public void toast(String msg){ Context context = getApplicationContext(); CharSequence text = msg; int duration = Toast.LENGTH_SHORT; Toast toast = Toast.makeText(context, text, duration); toast.show(); }
Then just call when you need, like this:
toast( "My message hardcoded" );
or with a link to strings.xml, like this:
toast( this.getString(R.string.toast_memoryshort) );
Víctor García
source share