logo
search
OneDrive File Issues

How to Upload Files to OneDrive for Business from an Android App

Huda QurayshiHuda Qurayshi Oct 14, 2026 869 views

Question details

The user needs to learn how to develop an Android application that can upload files directly to OneDrive for Business.

How to Upload Files to OneDrive for Business from an Android App
Product
Microsoft Graph API
Device & OS
Android
Scenario
Developing a custom Android application that integrates with Microsoft cloud services for file storage.
Observed behavior
The user is looking for correct API endpoints, authentication methods, and sample resources to implement file uploads to OneDrive via Microsoft Graph.
Before you start

Ensure you have an active Microsoft 365 developer account, access to the Azure portal for app registration, and basic knowledge of REST APIs and Android development.

Solution 1Recommended

Use Microsoft Graph API for File Uploads

This is the standard and recommended approach for interacting with OneDrive for Business in custom Android applications.

To upload files to OneDrive for Business, developers should utilize the Microsoft Graph API. This process involves registering your app in Azure AD to handle Microsoft identity services, obtaining an access token, and making a REST API call to upload the file content.

1
Register Your Application

Go to the Azure portal and register your Android application to use Microsoft identity services. Ensure you grant the necessary delegated permissions, such as Files.ReadWrite.

2
Implement User Authentication

Integrate the Microsoft Authentication Library (MSAL) for Android into your app. This will allow users to sign in and provide your app with a valid access token.

3
Construct the Upload Request

Include the obtained access token in the Authorization header of your HTTP request. To upload a file, make a PUT request to an endpoint like: PUT /drive/root:/path/to/file.txt:/content, placing the file content directly in the request body.

4
Reference Official Samples

Review the Microsoft Graph Developer Center and GitHub repositories like the 'Android Microsoft Graph snippets' for code examples and implementation details.

Use Microsoft Graph API for File Uploads
File Size Limitation: The simple PUT method is only suitable for files up to 4MB in size. For larger files, you will need to create an upload session using the Microsoft Graph API.
Free Microsoft Office alternative

Looking for an Office Suite with Seamless Cloud Integration?

While developing custom apps is great for specific needs, if you simply need a powerful mobile office solution to manage and edit files, try WPS Office. It natively supports OneDrive for Business and offers high compatibility with Microsoft Office formats in a lightweight app.

  1. 1. Install WPS Office: Download and install WPS Office from the Google Play Store on your Android device.
  2. 2. Access Cloud Services: Open the app, navigate to the 'Open' tab, and tap on 'Add Cloud Storage'.
  3. 3. Connect to OneDrive: Select 'OneDrive', sign in with your Microsoft credentials, and easily access or upload your documents directly within the app.
Native integration with OneDrive, Google Drive, and DropboxHighly compatible with Microsoft Word, Excel, and PowerPoint formatsLightweight app optimized for all Android devicesFree and intuitive user interface
microsoft office alternative - wps office

Frequently Asked Questions

What permissions do I need to upload files to OneDrive for Business via Microsoft Graph?

Your registered application requires delegated permissions such as Files.ReadWrite or Files.ReadWrite.All to successfully upload and modify files in a user's OneDrive for Business account.

How do I upload files larger than 4MB using Microsoft Graph?

For files exceeding 4MB, you cannot use the simple PUT method. Instead, you must use the createUploadSession endpoint to upload the file in manageable byte ranges.

Where can I find code snippets for Microsoft Graph on Android?

You can explore the Microsoft Graph Developer Center and search GitHub for official repositories like 'ms-identity-android-native' and 'android-java-snippets-rest-sample' to find ready-to-use code blocks.