This method is to detect file/proc/partitions.
Import java.io.*;
File Usbfile = new file ("/proc/partitions");
if (usbfile.exists ()) {
try {
FileReader file= New FileReader ("/proc/partitions");
BufferedReader br=new BufferedReader (file);
String strline= "";
while ((Strline=br.readline ())!=null)
{
if (Strline.indexof ("SD") >0)
{
LOG.D ("Debug_xyp", "Udisk insert---------->" +
"[" +thread.currentthread (). Getstacktrace () [2].getfilename () + "," +thread.currentthread (). Getstacktrace () [2]. Getlinenumber () + "]");
Break
}
}
Br.close ();
File.close ();
} catch (Exception e) {
E.printstacktrace ();
}
}
The file/proc/partitions content is probably as follows:
Major Minor #blocks name
179 0 3866624 Mmcblk0
179 1 655352 Mmcblk0p1
179 2 393208 MMCBLK0P2
179 3 524280 Mmcblk0p3
179 4 1 MMCBLK0P4
179 5 16376 MMCBLK0P5
179 6 16376 MMCBLK0P6
179 2048 MMCBLK0BOOT1
179 2048 Mmcblk0boot0
8 0 15360000 SDA
8 1 15355968 sda1
Android detects if one of the USB stick methods is inserted