How do i open a text file from a terminal window from within the android gui I'm trying to open a text file from within a terminal window emulator -- but not so it opens in the actual terminal but more like I've just clicked on it.

So my question is: What command can I use to open /mnt/sdcard/textfile.txt from a terminal window emulator from ROM Toolbox Lite within the Android GUI so that it will open with any one of my text editing applications? Will I need to run su before I can run what ever command? I'd prefer not to, but the device is rooted so I can run su.

Im using Android version 4.0.4
Launching apps in Android isn't straightforward. You'll have to use am start combined with certain &lt;PARAMS&gt; to launch the app or a particular section of it.

From the comments, it seems that you may want to launch the text file using ES Note Editor. In that case, first identify the activity responsible for the edit window you see when the file is opened in the editor using GUI.

Note: Tested the solution on Android 4.2, 4.4 and 5.0.

Instructions


Open the file manually in the editor using GUI, and make sure that it stays active on the screen.
Connect your phone into PC in debugging mode, setup ADB on PC, and enter into PC's terminal/cmd the commands:

adb shell
su
dumpsys activity | grep mFocusedActivity


The output may look like:

mFocusedActivity: ActivityRecord{42839028 u0 com.estrongs.android.pop/.app.editor.PopNoteEditor}


The relevant info (activity) is .app.editor.PopNoteEditor and package name is com.estrongs.android.pop. You may use the command dumpsys activity to see some more useful stuff.

That's just for brief understanding. Keep the whole string (com.estrongs.android.pop/.app.editor.PopNoteEditor) ready to be used.
You may close the editor on Android. Open your favorite terminal app in Android and enter:

su
am start -n &lt;PACKAGE_NAME/ACTIVITY&gt; -d &lt;FILEPATH&gt; --activity-clear-task



-n will allow to launch the app's mentioned component.
&lt;PACKAGE_NAME/ACTIVITY&gt; is the string we noted in step 2. For ES Note Editor it would be com.estrongs.android.pop/.app.editor.PopNoteEditor.
-d is to allow data to be passed to the app's activity.
&lt;FILEPATH&gt; is the location of the text file you want to open.
--activity-clear-task will make sure that the activity is not launched from "Recents" but from scratch.


(Enter am start to dive deeper into interesting stuff.)

In my case, the final query for file aero.txt under /sdcard/airdroid/ looked like:

am start -n com.estrongs.android.pop/.app.editor.PopNoteEditor -d file:///sdcard/airdroid/aero.txt --activity-clear-task


The file opened successfully.
I use QuickEdit Text Editor as  default text editor and the relevant query looked like:

am start -n com.rhmsoft.edit/.activity.MainActivity -d file:///sdcard/airdroid/nmon.txt --activity-clear-task





Have fun!