Skip to main content
ubuntuask.com

Back to all posts

How to Save File In Public Storage With Android Kotlin?

Published on
4 min read
How to Save File In Public Storage With Android Kotlin? image

Best Mobile File Storage Solutions to Buy in April 2026

1 Simple Trending 10 Tier Rolling File Cart, Desk File Organizer with Wheels and Storage Drawers, Legal documents can be stored, Metal Mesh Paper Letter Storage Multi-Functional Clutter Cart, Black

Simple Trending 10 Tier Rolling File Cart, Desk File Organizer with Wheels and Storage Drawers, Legal documents can be stored, Metal Mesh Paper Letter Storage Multi-Functional Clutter Cart, Black

  • 10-TIER DESIGN: ORGANIZE MORE WITH SPACIOUS, EASY-TO-REACH TIERS.
  • VERSATILE USE: PERFECT FOR OFFICE, CLASSROOM, OR HOME ORGANIZATION NEEDS.
  • DURABLE & STYLISH: RUST-RESISTANT METAL AND WOODEN TOP FOR LASTING APPEAL.
BUY & SAVE
$36.97
Simple Trending 10 Tier Rolling File Cart, Desk File Organizer with Wheels and Storage Drawers, Legal documents can be stored, Metal Mesh Paper Letter Storage Multi-Functional Clutter Cart, Black
2 Sbanmao Rolling File Cart, Mobile File Cabinet with Wheels Hanging Files, Metal Hanging File Folder Cart File Organizer Fit Letter Size for Home Office, Black

Sbanmao Rolling File Cart, Mobile File Cabinet with Wheels Hanging Files, Metal Hanging File Folder Cart File Organizer Fit Letter Size for Home Office, Black

  • VERSATILE STORAGE: PERFECT FOR HOME, OFFICE, OR CLASSROOM ORGANIZATION.
  • EASY MOBILITY: FOUR LOCKABLE CASTERS FOR SMOOTH, STABLE MOVEMENT.
  • DURABLE DESIGN: STURDY METAL CONSTRUCTION ENSURES LONG-LASTING USE.
BUY & SAVE
$59.99
Sbanmao Rolling File Cart, Mobile File Cabinet with Wheels Hanging Files, Metal Hanging File Folder Cart File Organizer Fit Letter Size for Home Office, Black
3 Vaultz Portable File Storage Box with Handle - 14.5" x 17.5" x 15.5" Letter/Legal Size Mobile Lock Box - Double Combination Locking Cabinet - Black

Vaultz Portable File Storage Box with Handle - 14.5" x 17.5" x 15.5" Letter/Legal Size Mobile Lock Box - Double Combination Locking Cabinet - Black

  • SECURE YOUR ESSENTIALS: DUAL-COMBINATION LOCKS FOR ADDED PROTECTION.

  • EFFORTLESS MOBILITY: SMOOTH WHEELS AND TELESCOPING HANDLE FOR EASY TRANSPORT.

  • VERSATILE STORAGE: IDEAL FOR HOME, OFFICE, AND TRAVEL-STORE DOCUMENTS SECURELY!

BUY & SAVE
$99.99
Vaultz Portable File Storage Box with Handle - 14.5" x 17.5" x 15.5" Letter/Legal Size Mobile Lock Box - Double Combination Locking Cabinet - Black
4 Huxitocan 2 Drawer File Cabinet with Adjustable Dividers, 4-Tier Mobile Vertical Filing Cabinet on Lockable Wheels, Hanging File Organizer Cart for Letter-Size,Rolling Utility Cart for Home Office

Huxitocan 2 Drawer File Cabinet with Adjustable Dividers, 4-Tier Mobile Vertical Filing Cabinet on Lockable Wheels, Hanging File Organizer Cart for Letter-Size,Rolling Utility Cart for Home Office

  • SPACE-SAVING DESIGN: LARGE CAPACITY WITH A COMPACT FOOTPRINT.
  • OPTIMAL VISIBILITY: TRANSPARENT DRAWERS PREVENT LOST SUPPLIES.
  • VERSATILE USE: PERFECT FOR OFFICES, CLASSROOMS, AND MORE.
BUY & SAVE
$38.99
Huxitocan 2 Drawer File Cabinet with Adjustable Dividers, 4-Tier Mobile Vertical Filing Cabinet on Lockable Wheels, Hanging File Organizer Cart for Letter-Size,Rolling Utility Cart for Home Office
5 Pendaflex Mobile File Box with Handles, Easy Set Up, Collapse Down and Store Away, 13"W x 10"H x 6.5"D, Holds Letter Size Files, White (126119)

Pendaflex Mobile File Box with Handles, Easy Set Up, Collapse Down and Store Away, 13"W x 10"H x 6.5"D, Holds Letter Size Files, White (126119)

  • QUICK ACCESS TO FILES ANYWHERE WITH A LIGHTWEIGHT, PORTABLE DESIGN.
  • PATENT-PENDING FOLDABLE DESIGN FOR EASY SETUP AND STORAGE.
  • DURABLE, EASY-TO-CLEAN BOX PERFECT FOR HOME, OFFICE, OR CLASSROOM.
BUY & SAVE
$16.12
Pendaflex Mobile File Box with Handles, Easy Set Up, Collapse Down and Store Away, 13"W x 10"H x 6.5"D, Holds Letter Size Files, White (126119)
6 futaiphy Fireproof File Box with Wheels, Collapsible Rolling Fireproof Document Bag with Lock, Fireproof Box with Handle & Casters, Mobile Fireproof Document Storage for Legal/Letter Size Files

futaiphy Fireproof File Box with Wheels, Collapsible Rolling Fireproof Document Bag with Lock, Fireproof Box with Handle & Casters, Mobile Fireproof Document Storage for Legal/Letter Size Files

  • EFFORTLESS PORTABILITY: LOAD AND GO WITH SMOOTH-ROLLING CASTERS!

  • ULTIMATE PROTECTION: SAFEGUARD DOCUMENTS FROM FIRE AND WATER DAMAGE.

  • SECURE STORAGE: LOCKING SYSTEM KEEPS SENSITIVE FILES SAFE AND PRIVATE.

BUY & SAVE
$75.99
futaiphy Fireproof File Box with Wheels, Collapsible Rolling Fireproof Document Bag with Lock, Fireproof Box with Handle & Casters, Mobile Fireproof Document Storage for Legal/Letter Size Files
7 EasyPAG Rolling Cart with Drawers, 8 Drawer Multipurpose Mobile Utility Storage Craft Cart, Metal Filing Cabinet for Home Office, Black

EasyPAG Rolling Cart with Drawers, 8 Drawer Multipurpose Mobile Utility Storage Craft Cart, Metal Filing Cabinet for Home Office, Black

  • VERSATILE DESIGN: USE IT AS AN OFFICE CART OR CRAFT UTILITY CART.

  • EASY MOBILITY: 360° ROLLING CASTERS FOR EFFORTLESS MOVEMENT AND STABILITY.

  • SPACE-SAVING SOLUTIONS: 8 DRAWERS MAXIMIZE STORAGE IN COMPACT AREAS.

BUY & SAVE
$129.99
EasyPAG Rolling Cart with Drawers, 8 Drawer Multipurpose Mobile Utility Storage Craft Cart, Metal Filing Cabinet for Home Office, Black
8 VASAGLE File Cabinet, Mobile Pedestal Filing Cabinet with Wheels, Printer Stand with 5 Drawers, Tool-Free Sliding Rails, for Study, Home Office, Cloud White UOFC081W01

VASAGLE File Cabinet, Mobile Pedestal Filing Cabinet with Wheels, Printer Stand with 5 Drawers, Tool-Free Sliding Rails, for Study, Home Office, Cloud White UOFC081W01

  • TOOL-FREE ASSEMBLY SAVES 50% TIME-QUICK SETUP FOR BUSY ENVIRONMENTS!

  • FIVE SPACIOUS DRAWERS KEEP YOUR WORKSPACE ORGANIZED AND CLUTTER-FREE.

  • SMOOTH-ROLLING WHEELS WITH LOCKS ENSURE EASY MOBILITY AND STABILITY.

BUY & SAVE
$79.99
VASAGLE File Cabinet, Mobile Pedestal Filing Cabinet with Wheels, Printer Stand with 5 Drawers, Tool-Free Sliding Rails, for Study, Home Office, Cloud White UOFC081W01
9 Sbanmao 4 Drawer Lateral File Cabinet, Mobile Filing Cabinet, Printer Stand with Wheels Under Desk Storage Office Storage Cabinet Fits Letter Size for Home Office, Black

Sbanmao 4 Drawer Lateral File Cabinet, Mobile Filing Cabinet, Printer Stand with Wheels Under Desk Storage Office Storage Cabinet Fits Letter Size for Home Office, Black

  • MAXIMIZE ORGANIZATION WITH 4 SPACIOUS DRAWERS FOR QUICK ACCESS.
  • EASILY MOVE AND SECURE WITH 6 SMOOTH-ROLLING WHEELS AND LOCKS.
  • STYLISH DESIGN DOUBLES AS A PRINTER STAND OR VERSATILE STORAGE SOLUTION.
BUY & SAVE
$59.99
Sbanmao 4 Drawer Lateral File Cabinet, Mobile Filing Cabinet, Printer Stand with Wheels Under Desk Storage Office Storage Cabinet Fits Letter Size for Home Office, Black
10 VASAGLE File Cabinet, Mobile Pedestal Filing Cabinet with Wheels, Printer Stand with 5 Drawers, Tool-Free Sliding Rails, for Study, Home Office, Ink Black UOFC081BC02

VASAGLE File Cabinet, Mobile Pedestal Filing Cabinet with Wheels, Printer Stand with 5 Drawers, Tool-Free Sliding Rails, for Study, Home Office, Ink Black UOFC081BC02

  • TOOL-FREE SETUP: SNAP TOGETHER IN MINUTES, CUTTING ASSEMBLY TIME BY 50%.

  • AMPLE STORAGE: 5 SPACIOUS DRAWERS FIT NEATLY UNDER STANDARD DESKS.

  • SMOOTH MOBILITY: ROLL EASILY WITH CASTERS; LOCK IN PLACE FOR SECURITY.

BUY & SAVE
$79.99
VASAGLE File Cabinet, Mobile Pedestal Filing Cabinet with Wheels, Printer Stand with 5 Drawers, Tool-Free Sliding Rails, for Study, Home Office, Ink Black UOFC081BC02
+
ONE MORE?

To save a file in public storage with Android Kotlin, you can use the following code snippet:

  1. Ensure that you have the necessary permissions in your AndroidManifest.xml file to write to external storage:

  2. Use the following Kotlin code to save a file to public storage:

val filename = "my_file.txt" val content = "Hello, this is some sample text to save in the file."

val file = File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), filename) file.createNewFile()

file.writeText(content)

This code snippet creates a new file named "my_file.txt" in the Downloads directory of the external storage and writes the content "Hello, this is some sample text to save in the file." to the file.

Remember to handle exceptions such as IOException when working with file operations in Android Kotlin.

How to read a text file from public storage on Android using Kotlin?

To read a text file from public storage on Android using Kotlin, you can follow these steps:

  1. Check for permission: Make sure you have the necessary permission to read files from external storage in your AndroidManifest.xml file. Add the following line:
  1. Create a function to read the text file:

fun readFileFromExternalStorage(fileName: String): String? { val file = File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), fileName) if (!file.exists()) { return null }

val text = StringBuilder()
try {
    val bufferedReader = BufferedReader(FileReader(file))
    var line: String?
    while (bufferedReader.readLine().also { line = it } != null) {
        text.append(line)
        text.append('\\n')
    }
    bufferedReader.close()
} catch (e: IOException) {
    e.printStackTrace()
}

return text.toString()

}

  1. Call the function with the name of the file you want to read:

val fileName = "example.txt" val fileContents = readFileFromExternalStorage(fileName) if (fileContents != null) { // Do something with the file contents Log.d("FileContents", fileContents) } else { Log.e("Error", "File not found") }

Make sure to handle the IOException that can be thrown while reading the file. Also, don't forget to request permission from the user at runtime if your app targets Android 6.0 (API level 23) or higher.

What is the impact of saving large files to public storage in terms of performance on Android with Kotlin?

Saving large files to public storage on an Android device can have a significant impact on performance, especially if the device has limited storage capacity or if the storage device is slow. Here are some potential impacts:

  1. Reduced storage space: Saving large files to public storage can consume a significant amount of storage space on the device, which may lead to slower performance and limited space for other apps and data.
  2. Slower read and write operations: If the storage device is slow, reading and writing large files can take longer and may impact the overall performance of the device. This can result in slower app load times and decreased responsiveness.
  3. Increased battery consumption: Reading and writing large files requires more processing power and can drain the device's battery faster. This can result in decreased battery life and reduced overall performance.
  4. Slower app performance: If an app is constantly reading and writing large files to public storage, it may lead to slower app performance, lag, and crashes. This can result in a poor user experience and decreased app usability.

To mitigate these impacts, developers can consider optimizing file sizes, using background threads for file operations, cleaning up temporary files, and implementing caching mechanisms to improve performance when dealing with large files on Android with Kotlin.

One recommended method for backing up files saved to public storage on Android with Kotlin is to use the BackupAgent API provided by the Android platform. This API allows you to implement backup and restore functionality for your app's data.

To use the BackupAgent API, you need to create a class that extends the BackupAgentHelper class and implement the necessary methods for backup and restore operations. You can specify which files and data to backup by overriding the getFilesToBackup() method.

You also need to declare the BackupAgent class in the AndroidManifest.xml file and enable backup functionality in the application's configuration by setting android:allowBackup="true" in the tag.

Additionally, you can use the SharedPreferences BackupHelper class provided by the Android platform to back up shared preferences data.

Overall, using the BackupAgent API is a recommended method for backing up files saved to public storage on Android with Kotlin as it provides a standardized and reliable way to handle backup and restore operations for your app's data.