I solved my problem as shown below, let it be useful for you.
if (mAdapter != null && mAdapter.getItemCount() > 0) {
final ArrayList<StoryModel> selectedList = mAdapter.getSelectedData();
if (selectedList.size() > 0) {
final ProgressDialog pd = new ProgressDialog(getActivity());
pd.setMessage("Saving Stories....");
pd.show();
Thread t = new Thread(new Runnable() {
@Override
public void run() {
try {
for (StoryModel imageModel : selectedList) {
String srcFilePath = imageModel.getUrl();
Log.d(TAG, "onOptionsItemSelected: " + srcFilePath);
org.apache.commons.io.FileUtils.copyFileToDirectory(new File(srcFilePath), new File(FileUtils.getAppPath(mContext)));
}
} catch (IOException ignored) {
}
Log.d(TAG, "run: Dismissed....");
pd.dismiss();
}
});
t.start();
} else {
Toast.makeText(mContext, R.string.string_error_select_story_to_download, Toast.LENGTH_LONG).show();
}
} else {
Toast.makeText(mContext, R.string.string_error_select_story_to_download, Toast.LENGTH_LONG).show();
}
Thank:)
source
share