Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. void createNewFolder( final int p_opt)
  2. {
  3.  
  4. final AlertDialog.Builder builder = new AlertDialog.Builder(this);
  5. builder.setTitle("Title");
  6.  
  7. // Set up the input
  8. final EditText m_edtinput = new EditText(this);
  9. // Specify the type of input expected;
  10. m_edtinput.setInputType(InputType.TYPE_CLASS_TEXT);
  11. // Set up the buttons
  12. builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
  13. @Override
  14. public void onClick(DialogInterface dialog, int which) {
  15. m_text = m_edtinput.getText().toString();
  16. if(p_opt == 1)
  17. {
  18. File m_newPath=new File(m_curDir,m_text);
  19. Log.d("cur dir",m_curDir);
  20. if(!m_newPath.exists()) {
  21. m_newPath.mkdirs();
  22. }
  23. }
  24. else
  25. {
  26. try {
  27. FileOutputStream m_Output = new FileOutputStream((m_curDir+File.separator+m_text), false);
  28. m_Output.close();
  29.  
  30. } catch (FileNotFoundException e)
  31. {
  32. e.printStackTrace();
  33. } catch (IOException e)
  34. {
  35. e.printStackTrace();
  36. }
  37. }
  38. getDirFromRoot(m_curDir);
  39.  
  40. }
  41. });
  42. builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
  43. @Override
  44. public void onClick(DialogInterface dialog, int which) {
  45. dialog.cancel();
  46. }
  47. });
  48.  
  49. builder.setView(m_edtinput);
  50. builder.show();
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement