In my project I want to share my referral code with app link.I already save referral code in SharedPreferences but I am unable to set that message in a separate class.
public static SharedPreferences sharedPreferences;
public static void shareMyApp(Context context) {
String link = "https://play.google.com/store/apps/details?id="+context.getPackageName()+"Signup with my referral code.My Code is "+sharedPreferences.getString("member_id",null);
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
sharingIntent.setType("text/*");
sharingIntent.putExtra(Intent.EXTRA_TEXT, link);
context.startActivity(Intent.createChooser(sharingIntent, "Share Via"));
}
This method is present inside a java class.When this method called an error appear.
java.lang.NullPointerException: Attempt to invoke interface method 'java.lang.String android.content.SharedPreferences.getString(java.lang.String, java.lang.String)' on a null object reference
How Can I print that code with app link?