How to find XML files on a project's folder?

 Is there a simple way to iterate over only the XML files on a project's folder? My goal is to change the body of the XML file by replacing 

"<uses-permission android:name=\"com.android.vending.BILLING\" />"; 

with 

"<uses-permission android:name=\"org.onepf.openiab.permission.BILLING\" />"; 
5 comments
Comment actions Permalink

Do you want to do this from the plugin? I'm asking because this can be done without any plugins, just invoke 'Replace in Path' action and specify *.xml as file mask.

0
Comment actions Permalink

Yes, because my plugin also does other things (non-involving XML).

0
Comment actions Permalink

You can use 

ProjectRootManager.getInstance(project).getFileIndex().iterateContent()

for that and filter xml files by comparing file.getFileType() with StdFileTypes.XML. This should be fast enough unless the project has several thousands of files.

0
Comment actions Permalink

Thank you for your help!

0
Comment actions Permalink

Can this be also done with a .AIDL file?

0

Please sign in to leave a comment.