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 December 2025

1 IRIS USA File Box with Lid File Organizer for Letter File w/Organizer-Lid, Plastic Mobile Filing Organizer, Water Resistant Document Box, Portable File Box with Handle, Secure Buckle, Lockable, Black

IRIS USA File Box with Lid File Organizer for Letter File w/Organizer-Lid, Plastic Mobile Filing Organizer, Water Resistant Document Box, Portable File Box with Handle, Secure Buckle, Lockable, Black

  • MAXIMIZE ORGANIZATION WITH 4-COMPARTMENT LID FOR SUPPLIES.
  • STURDY HANDLE AND SECURE LATCHES FOR EASY TRANSPORT AND SAFETY.
  • DEDICATED LOCK SPOT ENSURES DOCUMENT SECURITY FOR PROFESSIONALS.
BUY & SAVE
$16.14 $18.99
Save 15%
IRIS USA File Box with Lid File Organizer for Letter File w/Organizer-Lid, Plastic Mobile Filing Organizer, Water Resistant Document Box, Portable File Box with Handle, Secure Buckle, Lockable, Black
2 Office Depot Large Mobile File Box, Letter Size, 11 5/8in.H x 13 3/6in.W x 10in.D, Clear/Blue, 110988

Office Depot Large Mobile File Box, Letter Size, 11 5/8in.H x 13 3/6in.W x 10in.D, Clear/Blue, 110988

  • ACCOMMODATES LETTER-SIZE HANGING FILES FOR EASY ORGANIZATION.
  • LIGHTWEIGHT DESIGN WITH HANDLE FOR ON-THE-GO CONVENIENCE.
  • SECURE SNAP-TIGHT BUCKLE & LOCK FOR ULTIMATE CONTENT PROTECTION.
BUY & SAVE
$18.78 $19.99
Save 6%
Office Depot Large Mobile File Box, Letter Size, 11 5/8in.H x 13 3/6in.W x 10in.D, Clear/Blue, 110988
3 NODHM Metal Mobile File Cabinet, Rolling File Cart File Box with Sliding Cover and Wheels, Rolling Filing Cabinet Locking Tool Storage Cabinets for Home Classroom Office

NODHM Metal Mobile File Cabinet, Rolling File Cart File Box with Sliding Cover and Wheels, Rolling Filing Cabinet Locking Tool Storage Cabinets for Home Classroom Office

  • DURABLE STEEL BUILD: HIGH-STRENGTH, SCRATCH-RESISTANT DESIGN ENSURES LONGEVITY.

  • SECURE STORAGE: LOCKABLE SLIDING COVER AND TWO KEYS FOR ULTIMATE SECURITY.

  • VERSATILE MOBILITY: 360° CASTERS FOR EASY MOVEMENT IN ANY SETTING.

BUY & SAVE
$64.99
NODHM Metal Mobile File Cabinet, Rolling File Cart File Box with Sliding Cover and Wheels, Rolling Filing Cabinet Locking Tool Storage Cabinets for Home Classroom Office
4 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 DUAL-LOCKING SYSTEM FOR ULTIMATE PEACE OF MIND.

  • STURDY DESIGN WITH WHEELS FOR EASY MOBILITY ANYWHERE YOU NEED.

  • VERSATILE STORAGE SOLUTION FOR PERSONAL, OFFICE, AND TRAVEL USE.

BUY & SAVE
$89.99 $101.99
Save 12%
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
5 5 Drawer Mobile File Cabinet Under Desk Storage Organization with Wheels Vertical Filing Chest Rolling Wood Small Desk Printer Stand for Home Office, White

5 Drawer Mobile File Cabinet Under Desk Storage Organization with Wheels Vertical Filing Chest Rolling Wood Small Desk Printer Stand for Home Office, White

  • SPACIOUS 7-DRAWER DESIGN FOR ULTIMATE ORGANIZATION
  • QUIET, SMOOTH DRAWER OPERATION WITH STEEL BALL-BEARING SLIDES
  • DURABLE, WATERPROOF BUILD FOR LONG-LASTING USE
BUY & SAVE
$56.65 $79.99
Save 29%
5 Drawer Mobile File Cabinet Under Desk Storage Organization with Wheels Vertical Filing Chest Rolling Wood Small Desk Printer Stand for Home Office, White
6 SVYP Mobile Utility Cart with Storage Organizer Bag, Rolling Cart, Black/Grey

SVYP Mobile Utility Cart with Storage Organizer Bag, Rolling Cart, Black/Grey

  • EFFORTLESS TRANSPORT: MULTIPURPOSE DESIGN HAULS GROCERIES, TOOLS & MORE.
  • SMART STORAGE: 30+ COMPARTMENTS KEEP ITEMS SECURE AND ORGANIZED.
  • EASY PORTABILITY: ADJUSTABLE HANDLE AND SMOOTH WHEELS FOR HASSLE-FREE USE.
BUY & SAVE
$54.99
SVYP Mobile Utility Cart with Storage Organizer Bag, Rolling Cart, Black/Grey
7 LYS Mobile Wire Filing Cart

LYS Mobile Wire Filing Cart

  • CONVENIENTLY HOLDS LETTER-SIZE HANGING FILES FOR EASY ORGANIZATION.
  • EFFORTLESS MOBILITY WITH 4 SWIVEL, DUAL-WHEEL CASTERS.
  • DURABLE METAL WIRE FRAME WITH A SLEEK POWDER-COAT FINISH.
BUY & SAVE
$32.85
LYS Mobile Wire Filing Cart
8 7 Drawer Mobile File Cabinet Under Desk Storage Organization with Wheels Vertical Filing Chest Rolling Wood Small Desk Printer Stand for Home Office, Black

7 Drawer Mobile File Cabinet Under Desk Storage Organization with Wheels Vertical Filing Chest Rolling Wood Small Desk Printer Stand for Home Office, Black

  • SPACIOUS 7-DRAWER DESIGN: DECLUTTER EFFORTLESSLY WITH VERSATILE STORAGE.

  • SMOOTH, QUIET DRAWERS: ENJOY NOISELESS OPERATION WITH BALL-BEARING SLIDES.

  • STYLISH & DURABLE BUILD: WATERPROOF AND SCRATCH-RESISTANT FOR LASTING ELEGANCE.

BUY & SAVE
$77.39 $95.99
Save 19%
7 Drawer Mobile File Cabinet Under Desk Storage Organization with Wheels Vertical Filing Chest Rolling Wood Small Desk Printer Stand for Home Office, Black
9 HOOBRO 7-Drawer File Cabinet, Wooden Office Cabinet with Drawers, Mobile Storage Filing Drawer for Home Office, Study, Easy Assembly, White WT07WJ01

HOOBRO 7-Drawer File Cabinet, Wooden Office Cabinet with Drawers, Mobile Storage Filing Drawer for Home Office, Study, Easy Assembly, White WT07WJ01

  • VERSATILE DESIGN FITS ANY SPACE: OFFICE, STUDIO, OR LIVING ROOM.

  • STYLISH WHITE FINISH AND STURDY BUILD ENHANCE ANY DECOR EFFORTLESSLY.

  • EASY ASSEMBLY WITH WHEELS FOR QUICK MOVEMENT AND STABILITY.

BUY & SAVE
$123.99
HOOBRO 7-Drawer File Cabinet, Wooden Office Cabinet with Drawers, Mobile Storage Filing Drawer for Home Office, Study, Easy Assembly, White WT07WJ01
10 Pendaflex Portable File Box with File Rails, Simple Document Storage, File Bin for Home and Office, Hinged Lid with Double Latch Closure, Black, 3 Black Letter Size Hanging Folders Included (41742AMZ)

Pendaflex Portable File Box with File Rails, Simple Document Storage, File Bin for Home and Office, Hinged Lid with Double Latch Closure, Black, 3 Black Letter Size Hanging Folders Included (41742AMZ)

  • PORTABLE DESIGN WITH HANDLE AND LATCHES FOR SECURE TRAVEL.
  • HOLDS 22 FOLDERS-IDEAL FOR HOME, WORK, AND CLASSROOM USE.
  • EASY TO CLEAN, WATER-RESISTANT EXTERIOR KEEPS DOCUMENTS SAFE.
BUY & SAVE
$28.56 $31.10
Save 8%
Pendaflex Portable File Box with File Rails, Simple Document Storage, File Bin for Home and Office, Hinged Lid with Double Latch Closure, Black, 3 Black Letter Size Hanging Folders Included (41742AMZ)
+
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.