0

I have a an android Setup Box in which 2gb internal Memory available and 8 gb external memory available and device has slots for connect USB device. I wanted to get Memory information of connected USB Device. Suppose i have connected more then one USB Device. I am getting connection Disconnection event using Broadcast Receiver. But if i wanted to get Memory information that i am unable to get. I am only able to get inbuilt external memory information Please Guide me.

I am very new to android development. I have tried this way

 private void sizeInfo(){
    File path = Environment.getDataDirectory();
    StatFs stat2 = new StatFs(path.getPath());
    long blockSize = stat2.getBlockSize();
    long availableBlocks = stat2.getAvailableBlocks();
    String format =  Formatter.formatFileSize(this, availableBlocks * blockSize);
  //  Log.d("space","Path : "+ path +"\n");
    Log.d("space","Available Space in GB : "+ format);
    String str = Environment.getExternalStorageState();
    //Log.d("Checking","Media "+Environment.isExternalStorageEmulated());
}

I am getting list of attached device by following

    private void updateDeviceList() {
    Log.d("Checking","updateDeviceList function");
    int DivCount =0;
    HashMap<String, UsbDevice> connectedDevices = mUsbManager.getDeviceList();
    if (connectedDevices.isEmpty()) {
        usbDevice = null;
        Log.d("Checking", "No Currently Device Conneted");

    } else {
        for (UsbDevice device : connectedDevices.values()) {
                DivCount++;
                Log.d("Device Info","DeviceId " +device.getDeviceId()+"\n");
                Log.d("Device Info","ProductId "+device.getProductId()+"\n");
                Log.d("Device Info","DeviceName "+device.getDeviceName()+"\n");
                Log.d("Device Info","DeviceClass "+device.getDeviceClass());
                String str = Build.MANUFACTURER;
                Log.d("Device Info","Model "+str);
                usbDevice =device;
                sizeInfo();
        }
    }
}

I am able to get attached device list but not able to getting memory information of removable usb

Deepak
  • 21
  • 6
  • `I am only able to get inbuilt external memory information` Why not of that usb drive? What is your actual problem? – greenapps Apr 12 '18 at 13:26
  • I have connected 2 usb device having capacity 8GB and 16GB but i am unable to get capacity of connected USB Device. it every time showing the space of inbuilt external memory not Connected USB Device. – Deepak Apr 13 '18 at 05:03
  • Then what is your code you used for it? – greenapps Apr 13 '18 at 06:05
  • Above code i am using – Deepak Apr 16 '18 at 05:03
  • You surely know that that code has nothing to do with usb. – greenapps Apr 16 '18 at 06:21
  • That's why i am asking help how to do that please help – Deepak Apr 16 '18 at 08:44
  • You should better explain what your actual problem is. I asked you to do so before. Just dumping some code does not make sense. `I am only able to get inbuilt external memory information` So explain why only of inbuild. – greenapps Apr 16 '18 at 09:13
  • I have attached the function using which i am getting the list of storage device attached to the device correctly but i want to get memory information of all attached device which i am not able to get by using **sizeinfo()** – Deepak Apr 16 '18 at 10:32
  • Of course not. `sizeinfo()` has nothing to do with those usb devices. You are not telling the real problem you focus now. – greenapps Apr 16 '18 at 10:47
  • I don't know how to get memory Information of USB Device my problem is to get memory information of usb device Please guide. I am new to android – Deepak Apr 16 '18 at 11:33
  • You already told that a hundred times. We know. But you should tell your actual problem. Why does `sizeinfo()` not work? What do you need to make it work? Describe your actual problem! – greenapps Apr 16 '18 at 12:29
  • Simply i want to know the memory information of the Removable device. I don't know why sizeinfo() is not working.May be i am doing something wrong. Every time you are asking actual problem simply for testing purpose i am working and want to know memory information of USB Device. Please help – Deepak Apr 16 '18 at 12:59
  • `I don't know why sizeinfo() is not working` Hard to believe. As you exactly know what it does. And you also know that it has nothing to do with your usb devices. You just call it for every usb device from the list. – greenapps Apr 16 '18 at 13:05
  • Still not getting confused – Deepak Apr 16 '18 at 13:11
  • Please Guide i am unable to get – Deepak Apr 17 '18 at 07:08
  • Why doesnt it work if you just call two, three, four times sizeinfo()? You are supposed to tell the actual problem you encounter in sizeinfo(). – greenapps Apr 17 '18 at 08:36
  • Yeah i called 2 3 times but all the time its showing the same information not usb device information. Please guide i tried to much but still unable to get – Deepak Apr 17 '18 at 12:58
  • `all the time its showing the same information` Of course it does! Why should it show different information? If you cannot explain that it shows the same information all the time than all stops. – greenapps Apr 17 '18 at 13:01
  • Please Help i don't know how to do that – Deepak Apr 18 '18 at 04:37

0 Answers0