Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6930809
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:29:45+00:00 2026-05-27T11:29:45+00:00

Ok, so I have a Android 3.1 tablet (Acer Iconia Tab, which is great

  • 0

Ok, so I have a Android 3.1 tablet (Acer Iconia Tab, which is great by the way) which I can use with Android USB API to connect with a USB Mass Storage Device (a simple USB memory stick).

I use USB Host mode, find the device, get permission to connect to it (using BroadcastReceiver). All works great. The problem is that I don’t know exactly what to do in order to copy a file from the External Storage Directory to the USB memory stick.

This is what I have so far:

final BroadcastReceiver mUsbReceiver = new BroadcastReceiver() {
    public void onReceive(Context context, Intent intent) {
        String action = intent.getAction();
        if (ACTION_USB_PERMISSION.equals(action)) {
            synchronized (this) {
            UsbDevice device = (UsbDevice) intent.getParcelableExtra(UsbManager.EXTRA_DEVICE);

            if (intent.getBooleanExtra(UsbManager.EXTRA_PERMISSION_GRANTED, false)) {
                if (device != null) {

                    // Got to a point where I should set up connection
                    // I'm setting up a very simple connection, just want some file transfer

                    UsbInterface intf = device.getInterface(0);
                    UsbEndpoint endpoint = intf.getEndpoint(0);
                    UsbDeviceConnection connection = UsbManager.openDevice(device);

                    if (connection.claimInterface(intf, true)) {
                        UtilsAndDialogs.print(getApplicationContext(), "Connected to device");

                        // Copy file to USB...

                    } else
                        UtilsAndDialogs.print(getApplicationContext(), "Could not connect!");
                }
            } else {
                UtilsAndDialogs.print(getApplicationContext(), "Permission denied");
                Log.d(UtilsAndDialogs.LOG_TAG, "Permission denied for device " + device);
            }
        }
    } 
};

I read the documentation on the Android Dev Usb Host but it’s not very explicit and I found a pretty good tutorial Android Usb Host Tutorial – AdbTest but it uses asynchronous communication.

I just want to know how should I set up the connection and use the endpoint (I didn’t get the endpoint part, why they are needed) to just be able to create a new file on the USB storage device and copy contents of a different file in there, probably using bulkTransfer() method.

Any hints or pointers to more explicit documentation would be greatly appreciated.

Thank you

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T11:29:45+00:00Added an answer on May 27, 2026 at 11:29 am

    Your connection is set up, the end points are basically flags on the device with information on data transfer.

    For your stick you need to do something like VV to figure out how many endpoints you have,

    UsbInterface intf = device.getInterface(0);
    // checks for 2 endpoints
    if (intf.getEndpointCount() != 2) {
    Toast toast = Toast.makeText(context, "could not find endpoint", duration);
    toast.show();
    return;
        }
    UsbEndpoint ep = intf.getEndpoint(0);
    if (ep.getType() == UsbConstants.USB_ENDPOINT_XFER_BULK) {
    if (ep.getDirection() == UsbConstants.USB_DIR_OUT) {
    

    this will let you figure out if the endpoint you’re interested in is a bulk (usb constants docs has other types) and if you can send data to or from the device at that endpoint (usb_dir_in to test for in). What endpoint you want is device specific, my example starts on 0, yours will be different

    To resave the file you need to do something like

    mConnection.bulkTransfer(mEndpointOut, bytes, 512, TIMEOUT);
    

    I have been saving the buffer each time it fills with a file output stream, this is probably inefficient (as I assume bulktransfer is already saving somewhere) but documentation is scarce.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a project for visualizing some data on tablet. I'll probably use android
I'm implementing an app for Android(API 10). I have few designs for tablet(supposedly) and
I am new to work with android tablet api level 12. I have created
Tablet: Acer A500 GEN1 Android 3.1 kernel 2.6.36.3 (API level 12) SipManager since API
I have an android tablet. I made a swf file with mouse events, it
I have to develop an application for an Android Tablet. This will do the
I have a Motorola Xoom tablet of Android and I am facing the problem
Recently I became the proud owner of an Android 4.0 tablet and have been
I have 3 .apk files in the Android folder on my xoom tablet but
I have designed an app for android tablets and it consists of a tab

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.