1I am new to Android Studio and have gone through a ton of tutorials. I add a share option in my share app for users and want also user choice to save files in internal storage. So please tell me how I can save the file onclick. Hopefully, someone should help me with this Thanks.
My Java Adapter Class
holder.cardView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(context, "URL : "+FileProvider.getUriForFile(
context,BuildConfig.APPLICATION_ID + ".provider", new File(apps.get(position).getApkPath())), Toast.LENGTH_SHORT).show();
Intent shareAPKIntent = new Intent();
shareAPKIntent.setAction(Intent.ACTION_SEND);
shareAPKIntent.putExtra(Intent.EXTRA_STREAM, FileProvider.getUriForFile(
context,BuildConfig.APPLICATION_ID + ".provider", new File(apps.get(position).getApkPath())
));
shareAPKIntent.addFlags(Intent.FLAG_GRANT_PREFIX_URI_PERMISSION);
shareAPKIntent.setType("application/vnd.android.package-archive");
context.startActivity(Intent.createChooser(shareAPKIntent,"Share APK"));
}
});
}