Usage Scenarios:
If I say I want to be able to access one of the directory ABC on my phone's SD card on my computer, are you just going to create a folder like "/mnt/sdcard/abc/"? That's true. However, if we add one more demand, it may not be the case. I want to be accessible on our PC, but the device Manager of the phone is not able to access this directory, and how to do it?
Solution:
For the above questions, we can add a "." Before the directory that needs to be created. No. As above can be written as "/mnt/sdcard/.abc/". The created directory is not accessible on our mobile phone (provided that the phone does not have root, even root, and does not install software like root Explorer). But if that's the case, our PC is also inaccessible. To access this directory, you also need to wrap it in one layer. The packaging method is as follows:
We can use a class like this to wrap:
public class Singlemediascanner implements Mediascannerconnectionclient {private Mediascannerconnection mms;private File Mfile;public Singlemediascanner (context context, File f) {mfile = F;mms = new Mediascannerconnection (context, this); m Ms.connect ();} @Overridepublic void onmediascannerconnected () {Mms.scanfile (Mfile.getabsolutepath (), null);} @Overridepublic void onscancompleted (String path, Uri uri) {mms.disconnect ();}}
The above is just a description of the use of mediascannerconnectionclient, in the later blog will be a detailed introduction and explanation of this class.
Use demonstration:
public class Mainactivity extends Activity { private static final String PATH = "/mnt/sdcard/.testdir/"; @Override protected void onCreate (Bundle savedinstancestate) { super.oncreate (savedinstancestate); Setcontentview (r.layout.activity_main); if (! zffilesystem.isdirexisted (Path)) { zffilesystem.createdir (path); } ZFFILESYSTEM.WRITEDATA2SD (PATH + "A.txt", "abcdef". GetBytes ()); Singlemediascanner scanner = new Singlemediascanner (mainactivity.this, New File (PATH + "a.txt"));} }
Precautions :
1. The current connection between the phone and the PC is the MTP connection mode. At present, I test, like Meizu, millet, these two mobile phones when connected to the computer will have the MTP connection mode hint. However, there are some phones or tablets are not, it is necessary to set-up storage--click on the upper right corner button after selecting the MTP connection.
source code Download:
http://download.csdn.net/detail/u013761665/8417407
Android mount with dot number (.) The folder or file that starts with