Android mount with dot number (.) The folder or file that starts with

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.