Reputation: 2452
In my app I have to edit some text files in device and have to upload it to server.
So I am using default editors in the device using
Intent intent = new Intent();
intent.setAction(android.content.Intent.ACTION_VIEW);
File file = new File(fileName);
intent.setDataAndType(Uri.fromFile(file), "text/plain");
getActivity().startActivity(intent);
Now problem is, if the file gets edited I have to upload the file to server while coming back from default editor.
Is there any best and recommended way to get the status of the file while coming back to app from default editor.
Upvotes: 0
Views: 84
Reputation: 188
I don't think that there is a "best" way to do it, unless the editor gives you some feedback within the Intent
so you can catch it with onActivityResult
If is not your own editor and it does not implements a result after the job is done, then you can verify the file last modified date.
File file = new File(getResources().getString(R.string.file_name));
if (file.exists()) {
Date lastModified = new Date(file.lastModified());
}
You will have to store the date of the last modify just before you launch the editor, then if after coming back from the editor the last modify date changes you handle it.
Upvotes: 2