I want my app to open a plain text file with any of the file editors installed on my terminal, but I keep getting this exception:
ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.EDIT dat=file:///sdcard/folder/file.txt }
First I thought that I have no File editor installed, but if I use ASTRO file manager, I can get to open the file both with "File Editor" and "QuickOffice", so I think the problem is that I'm not using the right code...
Here is the code
Intent intent = new Intent(Intent.ACTION_EDIT);
Uri uri = Uri.parse("file:///sdcard/folder/file.txt");
intent.setDataAndType(uri, "plain/text");
startActivity(intent);
What is more surprising is that if I use the path of a file that doesn't exist, it keeps raising the same exception...
Thanks
Create a File with Touch Command The easiest way to create a new file in Linux is by using the touch command. The ls command lists the contents of the current directory. Since no other directory was specified, the touch command created the file in the current directory.
In a Windows Microsoft Word document, click the Save As button from the File menu. Select Save As Type from the drop-down list then select Plain Text (*. txt). Click the Save button and a File Conversion window will open.
Windows 10 Microsoft provides a way of creating a new, blank text file using the right-click menu in File Explorer. Open File Explorer and navigate to the folder where you want to create the text file. Right-click in the folder and go to New > Text Document. The text file is given a default name, New Text Document.
The MIME type is text/plain
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With