1

NOTE: my question is indeed similar to the question above. However, there is a slight difference, which I explain below in my ADDENDUM section.

Original question ...

I am creating lots of text files on my Oreo-based Android device with various file extensions besides simply .txt. For example, I have files with .xyz extensions, .abc extensions, and others, and I want all files with these particular suffixes to be seen as text files by my chosen text editor app. This way, whenever I select such a file, the system will choose that text editor to open them.

I have not found any way to do this, especially given that there is no default file association for text files that is offered in Android. But even if such a default text-file association were to exist, I don't know how to cause ad hoc filename suffixes to be associated with text files.

Furthermore, intents seem to operate on mime types, and I don't know how to associate these extra suffixes with text/plain under Android.

Is there any way in Android (Oreo) for me to accomplish what I want?

Thank you in advance.

ADDENDUM: The post referenced above talks about how mime types are managed on an application-specific basis in Android, and that there is no official way to manage mime types on a system-wide basis.

I understand this, but I am asking something slightly different. Suppose an application is already configured in its manifest to respond to text-plain items. My question is this: where in Android is the .txt suffix defined as corresponding to text-plain, and is there any way to add more suffixes (such as .abc and .xyz, as I describe above) on a system-wide basis to also be mapped to text-plain?

I have a rooted device that makes use of Xposed and Magisk, and so even if there is no official way in Android to implement these kinds of mappings, I'm wondering if there might be any unofficial Xposed or Magisk modules that will enable this. I couldn't find any such Xposed or Magisk modules, but perhaps I'm overlooking something.

Also, since my device is rooted (and I also am able to change my selinux settings to permissive), I could manually edit system configuration files anywhere on the device to add more filename suffixes to the text-plain mapping, assuming that this mapping is indeed managed in some sort of system configuration file.

I also run Tasker, and if such a mime configuration file exists, I could make sure that Tasker always copies a special version of that file in place during boot-up. In addition, I run other utitilies which allow ad hoc scripts to be run at startup via init.d.

Any thoughts? ...

  • Use a different file manager (e.g. Solid Explorer), it lets you choose from different apps to open those kind of file extension – HEWhoDoesn'tKnow Oct 26 '18 at 1:04
  • Thank you, but I want to associate plain/text with these items even if they are opened outside of a file manager ... i.e., via an arbitrary app. Is that not possible? – HippoMan Oct 26 '18 at 12:11
  • 1
    Possible duplicate of How to assign default app to unlisted file type – Morrison Chang Oct 28 '18 at 4:22
0

The following looks like a promising answer ...

The file /system/lib/content-types.properties contains the following info. It looks like I can add abc=text/plain and xyz=text/plain to this file in order to get my desired behavior. I'll test this and report back.

# If you want to support more recognized mimetypes in libcore.net.MimeUtils, add them here

docm=application/vnd.ms-word.document.macroenabled.12
xlsb=application/vnd.ms-excel.sheet.binary.macroenabled.12
xlsm=application/vnd.ms-excel.sheet.macroenabled.12
ppsm=application/vnd.ms-powerpoint.slideshow.macroenabled.12
ppsx=application/vnd.openxmlformats-officedocument.presentationml.slideshow
pptm=application/vnd.ms-powerpoint.presentation.macroenabled.12

asm=text/x-asm
cc=text/x-c
conf=text/plain
cpp=text/x-c
css=text/css
c=text/x-c
cxx=text/x-c
def=text/plain
dic=text/x-c
f77=text/x-fortran
f90=text/x-fortran
for=text/x-fortran
f=text/x-fortran
hh=text/x-c
hpp=text/x-c
h=text/x-c
ics=text/calendar
ifb=text/calendar
in=text/plain
jad=text/vnd.sun.j2me.app-descriptor
java=text/x-java-source
ksh=text/plain
list=text/plain
log=text/plain
pas=text/x-pascal
pl=text/plain
properties=|
prop=text/plain
p=text/x-pascal
py=text/x-python
rc=text/plain
sgml=text/sgml
sgm=text/sgml
s=text/x-asm
vcs=text/x-vcalendar
  • Sadly, when I put entries such as abc=text/plain into this file, their existence seems to be ignored, even after I reboot the device. So ... back to the drawing board ... – HippoMan Oct 29 '18 at 22:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.