Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. butImportPatient.setOnClickListener(new View.OnClickListener() {
  2.  
  3. @Override
  4. public void onClick(View view) {
  5. Intent intent = new Intent();
  6. intent.setAction(Intent.ACTION_OPEN_DOCUMENT);
  7. intent.setType("*/*");
  8. startActivityForResult(intent, IMPORTPATIENT_ACTIVITY_REQUEST_CODE);
  9. }
  10. });
  11.  
  12. @Override
  13. protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  14.  
  15. if (requestCode == IMPORTPATIENT_ACTIVITY_REQUEST_CODE && resultCode == RESULT_OK) {
  16. File file = new File(data.getData().getPath()) ;
  17. String path = file.getAbsolutePath() ;
  18. StringBuilder text = new StringBuilder();
  19.  
  20. try {
  21. BufferedReader br = new BufferedReader(new FileReader(path));
  22. String line;
  23.  
  24. while ((line = br.readLine()) != null) {
  25. text.append(line);
  26. text.append("n");
  27.  
  28. }
  29. br.close();
  30. } catch (IOException e) {
  31. e.printStackTrace();
  32. }
  33.  
  34. AlertDialog.Builder builder = new AlertDialog.Builder(this) ;
  35. builder.setMessage(path)
  36. .show() ;
  37.  
  38. }
  39. }
  40.  
  41. /document/home:List.txt
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement