Android java :Passing with the path between two activity - java

I'm new in android developing and currently develop an CalendarNote app.
By pick the date to create a folder and the folder name is the date.
After pick the date and successfully created the date folder move to
text interface.
create folder and text interface are two different activity.
Now, the problem is I want to save the txt file to the folder that
I just created.
I try to getText from the date I picked to the text activity, but
not successful.
I did a lot of research and tried a lot related code, still not success.
Anyone can please help me or give me some guide so that I won't lost . Thanks.
The following bellow is the create folder code:
btn_cFolder.setOnClickListener(new OnClickListener() {
public void onClick(View v)
{
String dateN = edit_date.getText().toString();
new AlertDialog.Builder(DatePickerActivity.this, AlertDialog.THEME_HOLO_DARK)
.setTitle("Create Folder")
.setMessage("Confirm to create " + dateN +" folder ?")
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
Environment.getExternalStorageDirectory();
String dateN = edit_date.getText().toString();
edit_date.setTypeface(edit_date.getTypeface(), Typeface.BOLD_ITALIC);
File folder = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/CalendarNote/" + dateN);
boolean success = true;
if (!folder.exists()) {
success = folder.mkdirs();
}
if (success) {
Toast.makeText(getBaseContext(), "You have successfully created." , Toast.LENGTH_LONG ).show();
Intent w = new Intent(DatePickerActivity.this, SelectTypeActivity.class);
startActivity(w);
} else {
Toast.makeText(getBaseContext(), "You have Failed to create." , Toast.LENGTH_LONG ).show();
}
}
})
.setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// do nothing
}
})
.setIcon(R.drawable.ic_launcher)
.show();
}
});
And this is the create txt file code:
public void SaveListener() {
imb_savefile = (ImageButton) findViewById(R.id.imb_savefile);
imb_savefile.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View arg0) {
edit_date = (EditText) findViewById(R.id.edit_date);
String t = edit_title.getText().toString();
new AlertDialog.Builder(WriteNoteActivity.this, AlertDialog.THEME_HOLO_DARK)
.setTitle("Save Note")
.setMessage("Confirm to save " + t +"?")
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
String content = edit_content.getText().toString();
String title = edit_title.getText().toString();
String dateN = edit_date.getText().toString();
boolean success = true;
try {
File sdCardDir = Environment.getExternalStorageDirectory();
File targetFile;
targetFile = new File(sdCardDir.getCanonicalPath()
+ "/CalendarNote/"+ dateN);
File file=new File(targetFile + "/"+title+".txt");
if(!targetFile.exists()){
success = targetFile.mkdir();
}
RandomAccessFile raf = new RandomAccessFile(file, "rw");
raf.seek(file.length());
raf.write(content.getBytes());
raf.close();
} catch (IOException e) {
e.printStackTrace();
}
if (success) {
Toast.makeText(getBaseContext(), "You have successfully created." , Toast.LENGTH_LONG ).show();
} else {
Toast.makeText(getBaseContext(), "You have Failed to create." , Toast.LENGTH_LONG ).show();
}
//Toast.makeText(getBaseContext(), "Note have successfully saved." , Toast.LENGTH_LONG ).show();
}
})
.setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(getBaseContext(), "Note Cancelled." , Toast.LENGTH_LONG ).show();
}
})
.setIcon(R.drawable.ic_launcher)
.show();
}
});
}
The dateN is the key to create folder .
[Updateted 15/3/2014]
Hi actually after pick the date (DatePickerActivity) >> select type of note (SelectTypeActivity) >> write the txt file (WriteNoteActivity). This is the process. So far i use #Hamid Shatu suggestion this is really helpful ! But I have to change the intent SelectTypeActivity.class to WriteNoteActivity.class like this it will success, how can I no need to skip the SelectTypeActivity also able to do that ? =)
Sorry for my broken English.

Pass your folder path to SelectTypeActivity through putExtra() method of Intent as below...
String folderPath = Environment.getExternalStorageDirectory().getAbsolutePath() + "/CalendarNote/" + dateN;
File folder = new File(folderPath);
boolean success = true;
if (!folder.exists()) {
success = folder.mkdirs();
}
if (success) {
Toast.makeText(getBaseContext(), "You have successfully created." , Toast.LENGTH_LONG ).show();
Intent w = new Intent(DatePickerActivity.this, SelectTypeActivity.class);
w..putExtra("folderpath", folderPath);
startActivity(w);
} else {
Toast.makeText(getBaseContext(), "You have Failed to create." , Toast.LENGTH_LONG ).show();
}
Retrieve that folder path from Extra using getStringExtra() method in SelectTypeActivity class as below...
//File sdCardDir = Environment.getExternalStorageDirectory();
//File targetFile;
//targetFile = new File(sdCardDir.getCanonicalPath()
+ "/CalendarNote/"+ dateN);
String folderPath = getIntent().getStringExtra("folderpath");
File file=new File(folderPath + "/"+title+".txt");

Related

Check if a file exists in Android

Android/Java, API level 12.
I'm trying to check if a .zip file exists in the Downloads folder. If it doesn't exist then I'm downloading it from the internet using DownloadManager. For the purposes of testing I'm running my checkIfFileExists immediately after the onReceive method of the DownloadManager, subject to the download being successful. My issue is that checkIfFileExists is returning false every time, even after I've just downloaded the file and I've checked manually that it does exist.
The relevant code is below.
DownloadManager dm;
long queueid;
String filename = "myfile.zip", url = "http://myurl/", uriString = "";
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
[...]
BroadcastReceiver receiver = new BroadcastReceiver() {
#Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (DownloadManager.ACTION_DOWNLOAD_COMPLETE.equals(action))
{
DownloadManager.Query req_query = new DownloadManager.Query();
req_query.setFilterById(queueid);
Cursor c = dm.query(req_query);
if (c==null)
{
Toast.makeText(context, "Download not found!", Toast.LENGTH_SHORT).show();
}
else
{
if (c.moveToFirst())
{
int columnIndex = c.getColumnIndex(DownloadManager.COLUMN_STATUS);
if (DownloadManager.STATUS_SUCCESSFUL==c.getInt(columnIndex))
{
uriString = c.getString(c.getColumnIndex(DownloadManager.COLUMN_LOCAL_URI));
Toast.makeText(context, "Download finished.", Toast.LENGTH_SHORT).show();
Toast.makeText(context, uriString, Toast.LENGTH_LONG).show();
checkIfFileExists();
}
}
}
}
}
};
registerReceiver(receiver, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));
}
public void onClickDownload(View v) // this method seems to be working with no issues.
{
dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));
request.setDestinationInExternalFilesDir(this, Environment.DIRECTORY_DOWNLOADS, filename);
queueid = dm.enqueue(request);
}
private boolean checkIfFileExists()
{
File file = new File(uriString);
if(file.exists())
{
Toast.makeText(this, "Exists", Toast.LENGTH_SHORT).show();
return true;
}
else
{
Toast.makeText(this, "Doesn't exist", Toast.LENGTH_SHORT).show();
return false;
}
}
I was expecting if(file.exists()) to evaluate to true since the file does exist.
What actually happens is if(file.exists()) always evaluates as false.
Can anyone see what I'm doing wrong?
Change your method like this.:
private boolean checkIfFileExists(String zipName /*ex: fileName.zip*/) {
File file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), zipName);
if(file.exists()) {
Toast.makeText(this, "Exists", Toast.LENGTH_SHORT).show();
return true;
} else {
Toast.makeText(this, "Doesn't exist", Toast.LENGTH_SHORT).show();
return false;
}
}

Unable to rename and delete media files from media player app

I have made a media player app using Exoplayer. I am trying to implement the rename and delete functionality on the individual media files. But the operations are not working and file.renameTo(newFile) always returns false. I have checked other answers on StackOverflow about file permissions but it is not working. Please help!
Here is the code-
For deleting file
#Override
public void onClick(View view) {
AlertDialog.Builder alertDialog=new AlertDialog.Builder(context);
alertDialog.setTitle("Delete");
alertDialog.setMessage("Do you want to delete this file?");
alertDialog.setPositiveButton("Delete", new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialogInterface, int i) {
Uri contentUri=null;
if(mediaType.equals(MEDIA_TYPE_VIDEO))
contentUri= ContentUris.withAppendedId(MediaStore.Video.Media.EXTERNAL_CONTENT_URI,
Long.parseLong(mediaList.get(holder.getAbsoluteAdapterPosition()).getId()));
else if(mediaType.equals(MEDIA_TYPE_AUDIO))
contentUri=ContentUris.withAppendedId(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
Long.parseLong(mediaList.get(holder.getAbsoluteAdapterPosition()).getId()));
else
Toast.makeText(context.getApplicationContext(), "wrong media type!",Toast.LENGTH_SHORT).show();
File file=new File(mediaList.get(holder.getAbsoluteAdapterPosition()).getPath());
Log.i(TAG+" ###",""+file.getName());
boolean delete=file.delete();
if(delete)
{
context.getContentResolver().delete(contentUri,null,null);
mediaList.remove(holder.getAbsoluteAdapterPosition());
notifyItemRemoved(holder.getAbsoluteAdapterPosition());
notifyItemRangeChanged(holder.getAbsoluteAdapterPosition(),mediaList.size());
Toast.makeText(context,"File deleted successfully!",Toast.LENGTH_SHORT).show();
}
else
{
Toast.makeText(context,"Media file deletion failed!",Toast.LENGTH_SHORT).show();
}
}
});
alertDialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
}
});
alertDialog.show();
bottomSheetDialog.dismiss();
}
});```
**For renaming file-**
```bsView.findViewById(R.id.bs_rename).setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
AlertDialog.Builder alertDialog = new AlertDialog.Builder(context);
alertDialog.setTitle("Rename To");
EditText editText = new EditText(context);
String path = mediaList.get(holder.getAbsoluteAdapterPosition()).getPath();
final File file = new File(path);
String mediaName = file.getName();
mediaName = mediaName.substring(0, mediaName.lastIndexOf("."));
editText.setText(mediaName);
alertDialog.setView(editText);
editText.requestFocus();
alertDialog.setPositiveButton("OK", new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialogInterface, int i) {
//Apply validation check
if(TextUtils.isEmpty(editText.getText().toString()))
{
Toast.makeText(context,"Can't rename empty file",Toast.LENGTH_SHORT).show();
return;
}
String onlyPath = file.getParentFile().getAbsolutePath();
Log.i(TAG + " ###", "Original Path: " + onlyPath);
String ext = file.getAbsolutePath();
Log.i(TAG + " ###", "ext: file.getAbsolutePath(): " + ext);
ext = ext.substring(ext.lastIndexOf("."));
Log.i(TAG + " ###", "ext: file.getAbsolutePath(): " + ext);
String newPath = onlyPath + "/" + editText.getText().toString().trim() + ext;
Log.i(TAG + " ###", "New Path: " + newPath);
File newFile = new File(newPath);
Log.i(TAG+" ###","renaming: in onClick(): newFile name: "+newFile.getName());
boolean rename=false;
try {
rename = file.renameTo(newFile);
Log.i(TAG+" ###","file name after renaming: "+file.getName());
} catch (Exception e) {
Log.e(TAG + " ###", "Exception while renaming: " + e);
}
Log.i(TAG + " ###", "rename: " + rename);
if (rename) {
ContentResolver resolver = context.getApplicationContext().getContentResolver();
resolver.delete(MediaStore.Files.getContentUri("external"),
MediaStore.MediaColumns.DATA + "=?", new String[]
{
file.getAbsolutePath()
});
Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
intent.setData(Uri.fromFile(newFile));
context.getApplicationContext().sendBroadcast(intent);
notifyDataSetChanged();
Toast.makeText(context, "File Renamed", Toast.LENGTH_SHORT).show();
//To show the instantaneous change in the name
//Otherwise we have to close and reopen the app to see the change
SystemClock.sleep(200);
((Activity) context).recreate();//automatically refreshes the activity
} else {
Toast.makeText(context, "Process Failed!", Toast.LENGTH_SHORT).show();
}
}
});
alertDialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialogInterface, int i) {
//dismiss the dialog
dialogInterface.dismiss();
}
});
alertDialog.create().show();
bottomSheetDialog.dismiss();
}
});```
I have set the following permissions in the Manifest file-
```<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission
android:name="android.permission.MANAGE_EXTERNAL_STORAGE"
tools:ignore="ScopedStorage" />
<uses-permission
android:name="android.permission.WRITE_SETTINGS"
tools:ignore="ProtectedPermissions" />
<uses-permission android:name="android.permission.CHANGE_SYSTEM_SETTINGS" />```

Android java : delete selected file / folder

How to delete the selected file / folder by using long pressed ?
I'm developing an File Explorer app and there are listed folder and file from my storage.
I want to have a delete function for the longpressed().
public void longpressed(){
this.getListView().setLongClickable(true);
this.getListView().setOnItemLongClickListener(new OnItemLongClickListener() {
public boolean onItemLongClick(AdapterView<?> parent, View v, int position, long id) {
new AlertDialog.Builder(ViewNoteActivity.this , AlertDialog.THEME_HOLO_DARK)
.setTitle("Delete Folder / File")
.setMessage("Are you sure you want to delete the selected folder / file ?")
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which ) {
boolean success = true;
if (success) {
Toast.makeText(getBaseContext(), "You have successfully delete." , Toast.LENGTH_SHORT ).show();
} else {
Toast.makeText(getBaseContext(), "You have Failed to delete." , Toast.LENGTH_SHORT ).show();
}
}
})
.setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// do nothing
}
})
.setIcon(R.drawable.ic_launcher)
.show();
return true;
}
});
}
item select coding:
#Override
protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
FileInfo fileDescriptor = fileArrayListAdapter.getItem(position);
if (fileDescriptor.isFolder() || fileDescriptor.isParent()) {
currentFolder = new File(fileDescriptor.getPath());
fill(currentFolder);
} else {
fileSelected = new File(fileDescriptor.getPath());
Intent intent = new Intent();
intent.putExtra(Constants.KEY_FILE_SELECTED,
fileSelected.getAbsolutePath());
setResult(Activity.RESULT_OK, intent);
Log.i("FILE CHOOSER", "result ok");
}
}
See the File class API reference.
To delete a file:
new File(path).delete()
To delete a folder:
private void deleteFolderRecursive(File dir) {
File[] files = dir.listFiles();
if (files != null) {
for (File file : files) {
if (file.isDirectory()) {
deleteFolderRecursive(file);
} else {
file.delete();
}
}
}
dir.delete();
}
Do this:
File dir =new File(getActivity().getApplicationContext().getFilesDir()+"/YourFOlderName");
boolean success = deleteDir(dir);
Where:
getActivity().getApplicationContext().getFilesDir()+"/YourFOlderName"
is the path to the folder.
And:
public static boolean deleteDir(File dir) {
if (dir.isDirectory()) {
String[] children = dir.list();
for (int i=0; i<children.length; i++) {
boolean success = deleteDir(new File(dir, children[i]));
if (!success) {
return false;
}
}
}
return dir.delete();
}
The above will delete all the children inside the directory.
if your folder is on the External SD Card the path should be mounted like:
Never hardcode the sdcard, you must use
Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)
will let you know if the memory is loaded. Then use:
Environment.getExternalStorageDirectory().getAbsolutePath()

Duplicate screen shot of first fragment

I have 2 fragments. First one is a checklist for live electrical work(safety check list)
, and a second fragmet which is also a checklist (non- live electrical work).
What I'm doing is getting the user to take a screen shot of each fragment when they click "next". This is achieved by getting the user to click the "next" button which will take a screen shot of the current fragment, then loading the next fragment(goes from liveWorkFragment -> nonLiveWorkFragment). Same thing on the second fragment. The problem I am having is that the first fragment takes a screen shot no problem, it gets saved in the correct folder etc, but when I click next on the second fragment, it takes the screenshot, but when I go to look at the picture(fragment2 screenshot is called "SafetyCheckList2.png"), it's the same picture as fragment1. I have no idea why.
This is the code to take a screen shot for fragment1:
View.OnClickListener clickListener = new View.OnClickListener()
{
#Override
public void onClick(View v)
{
if(v.getId() == R.id.btnNext)
{
try
{
View u = view.findViewById(R.id.liveWorkLayout).getRootView();
u.setDrawingCacheEnabled(true);
Bitmap b = u.getDrawingCache();
//Setup the directory
File mediaFolder = new File(context.getExternalFilesDir(null)+"/ArcFlash/CheckListMedia");
if(!mediaFolder.exists())
mediaFolder.mkdirs();
File fileName = new File(context.getExternalFilesDir(null)+"/ArcFlash/SafetyCheckList1.png");//CheckListMedia
FileOutputStream out = new FileOutputStream(fileName);
b.compress(Bitmap.CompressFormat.PNG, 90, out);
out.close();
Toast.makeText(context, "Saved Picture", Toast.LENGTH_SHORT).show();
new AlertDialog.Builder(context)
.setTitle("Continue")
.setMessage("You cannot return to this page after clicking next.")
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
FragmentManager fm = getFragmentManager();
FragmentTransaction transaction = fm.beginTransaction();
Fragment newFragment = new NonLiveWorkFragment();
transaction.replace(R.id.mainLayout, newFragment);
//transaction.addToBackStack("first");
transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
transaction.commit();
}
})
.setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// do nothing
}
})
.show();
}
catch(Exception ex)
{
handler.Log(ex.getMessage(), "onClick (LiveWorkFragment.java)", context);
}
}
}
};
Code for fragment2:
View.OnClickListener clickListener = new View.OnClickListener()
{
#Override
public void onClick(View v)
{
if(v.getId() == R.id.frag2Next)
{
try
{
View u = view.findViewById(R.id.nonLiveWorkLayout).getRootView();
u.setDrawingCacheEnabled(true);
Bitmap b = u.getDrawingCache();
File fileName = new File(context.getExternalFilesDir(null)+"/ArcFlash/SafetyCheckList2.png");
FileOutputStream out = new FileOutputStream(fileName);
b.compress(Bitmap.CompressFormat.PNG, 90, out);
out.close();
Toast.makeText(context, "Saved Picture", Toast.LENGTH_LONG).show();
//Until I figure out how the heck to draw with a silly(being PG 13 here..) fragment,
//I'm going to use an activity as the final page
new AlertDialog.Builder(context)
.setTitle("Continue")
.setMessage("You cannot return to this page after clicking next.")
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
Intent signatures = new Intent();
signatures.setClass(getActivity(), Signature.class);
startActivity(signatures);
}
})
.setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// do nothing
}
})
.show();
}
catch(Exception ex)
{
handler.Log(ex.getMessage(), "onClick Next (NonLiveWorkFragment.java)", context);
Toast.makeText(context, "Couldn't load next page.", Toast.LENGTH_LONG).show();
}
}
}
};

How can I alter ths code to correctly save a file if it exists?

Currently I can load a text file into an EditText. If the text is changed and the user attempts to open a new file a "save first?" dialog is displayed. The problem I'm having is instead of saving the working file (currentFile) it saves over the file to be opened.
Where am I going wrong?
File currentFile;
public boolean changed;
public boolean exists;
...
private void openFile(final File aFile){
String nullChk = et.getText().toString();
exists = true;
if(!changed || nullChk.matches("")){
try {
et.setText(new Scanner(aFile).useDelimiter("\\Z").next());
changed=false;
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}else{
AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setTitle("Save first?");
alert.setMessage("(Will be saved in the current working directory)");
alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
String temptxt = et.getText().toString();
if(exists){
saveFile(aFile.getPath(), temptxt);
}else{
saveAs();
}
}
});
final File tempFile = aFile;
alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
try {
et.setText(new Scanner(tempFile).useDelimiter("\\Z").next());
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
changed=false;
}
});
alert.show();
//currentFile = aFile;
}
}
private void saveFile(String sFileName, String sBody){
//Toast.makeText(this, exists +"", Toast.LENGTH_SHORT).show();
if (exists) {
try {
File tempfile = new File(sFileName);
FileWriter writer = new FileWriter(tempfile);
writer.write(sBody);
writer.flush();
writer.close();
changed=false;
Toast.makeText(this, "Saved", Toast.LENGTH_SHORT).show();
return;
} catch (IOException e) {
e.printStackTrace();
}
}else{
Toast.makeText(this, "Save as", Toast.LENGTH_SHORT).show();
saveAs();
}
}
private void saveAs(){
AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setTitle("Save as");
alert.setMessage("(Will be saved in the current working directory)");
// Set an EditText view to get user input
final EditText input = new EditText(this);
alert.setView(input);
alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
String value = input.getText().toString();
String tmpText = et.getText().toString();
try {
File tempfile = new File(currentDirectory, value);
FileWriter writer = new FileWriter(tempfile);
writer.write(tmpText);
writer.flush();
writer.close();
changed=false;
fill(currentDirectory.listFiles());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
startActivityForResult(new Intent(MainActivity.this, NewFile.class),1);
dialog.dismiss();
}
});
alert.show();
}
I think you use same file to open and save files.
When you open file you use aFile as parameter openFile(final File aFile) and use aFile in
et.setText(new Scanner(aFile).useDelimiter("\\Z").next());
and
saveFile(aFile.getPath(), temptxt);.

Categories

Resources