The flow is:
For those who struggle to fix that code here is the fixed one
ab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("*/*");
startActivityForResult(intent, PICKFILE_RESULT_CODE);
}
});
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == PICKFILE_RESULT_CODE) {
Uri uri = data.getData();
LaterFunction(uri);
}
}
public void LaterFunction(Uri uri) {
BufferedReader br;
FileOutputStream os;
try {
br = new BufferedReader(new InputStreamReader(getContentResolver().openInputStream(uri)));
//WHAT TODO ? Is this creates new file with
//the name NewFileName on internal app storage?
os = openFileOutput("newFileName", Context.MODE_PRIVATE);
String line = null;
while ((line = br.readLine()) != null) {
os.write(line.getBytes());
Log.w("nlllllllllllll",line);
}
br.close();
os.close();
} catch (IOException e) {
e.printStackTrace();
}
}