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

1 LYS Mobile Wire Filing Cart

LYS Mobile Wire Filing Cart

  • STORE LETTER-SIZE FILES NEATLY FOR EASY ACCESS AND ORGANIZATION.
  • EFFORTLESS MOBILITY WITH 4 SWIVEL, DUAL-WHEEL CASTERS.
  • BOTTOM SHELF PROVIDES EXTRA STORAGE FOR OFFICE ESSENTIALS.
BUY & SAVE
$19.99 $29.09
Save 31%
LYS Mobile Wire Filing Cart
2 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

  • BUILT TO LAST: DURABLE ALL-STEEL DESIGN PREVENTS DEFORMATION & SCRATCHES.

  • SECURE STORAGE: LOCKABLE DESIGN KEEPS DOCUMENTS SAFE FROM UNAUTHORIZED ACCESS.

  • VERSATILE & MOBILE: ADJUSTABLE RODS AND 360° CASTERS FOR EASY MOVEMENT.

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
3 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

  • FITS STANDARD LETTER-SIZE HANGING FILES FOR EASY ORGANIZATION.
  • LIGHTWEIGHT DESIGN WITH A CARRYING HANDLE FOR ON-THE-GO USE.
  • SECURE SNAP-TIGHT BUCKLE AND LOCK FOR ADDED CONTENT PROTECTION.
BUY & SAVE
$19.99
Office Depot Large Mobile File Box, Letter Size, 11 5/8in.H x 13 3/6in.W x 10in.D, Clear/Blue, 110988
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 PROTECTION OF IMPORTANT DOCUMENTS.

  • PORTABLE DESIGN WITH WHEELS AND TELESCOPING HANDLE FOR EASY MOBILITY.

  • STURDY CONSTRUCTION WITH METAL RAILS TO KEEP FILES ORGANIZED AND SECURE.

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
5 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

  • ORGANIZE DOCUMENTS EASILY WITH CONVENIENT HANGING FILE LEDGE.
  • 4-COMPARTMENT ORGANIZER TOP FOR ESSENTIAL OFFICE SUPPLIES STORAGE.
  • SECURE LATCH AND LOCK SPOT FOR SAFE DOCUMENT TRANSPORT AND STORAGE.
BUY & SAVE
$18.99
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
6 Sbanmao 5 Drawer Mobile File Cabinet, Under Desk Mobile Filing Cabinet with Wheels, Vertical Metal Filing Chest Rolling Small Desk Printer Stand Storage Organization for Home Office, White

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

  • AMPLE 5-DRAWER STORAGE WITH SMOOTH SLIDES FOR EASY ACCESS.
  • DURABLE WOOD TOP & METAL FRAME; WATER AND RUST-RESISTANT DESIGN.
  • PORTABLE WITH LOCKING WHEELS; IDEAL FOR ANY ROOM OR OFFICE.
BUY & SAVE
$59.99
Sbanmao 5 Drawer Mobile File Cabinet, Under Desk Mobile Filing Cabinet with Wheels, Vertical Metal Filing Chest Rolling Small Desk Printer Stand Storage Organization for Home Office, White
7 HOOBRO 7-Drawer File Cabinet, Wooden Office Cabinet with Drawers, Mobile Storage Filing Drawer for Home Office, Study, Easy Assembly, Rustic Brown and Black BF07WJ01

HOOBRO 7-Drawer File Cabinet, Wooden Office Cabinet with Drawers, Mobile Storage Filing Drawer for Home Office, Study, Easy Assembly, Rustic Brown and Black BF07WJ01

  • PERFECT FIT FOR ANY SPACE: OFFICE, STUDIO, OR KITCHEN VERSATILITY.
  • ELEGANT VINTAGE CHARM: RUSTIC DESIGN ENHANCES YOUR DECOR EFFORTLESSLY.
  • EASY ASSEMBLY & MOBILITY: QUICK SETUP WITH ROLLING CASTERS FOR FLEXIBILITY.
BUY & SAVE
$109.99 $119.99
Save 8%
HOOBRO 7-Drawer File Cabinet, Wooden Office Cabinet with Drawers, Mobile Storage Filing Drawer for Home Office, Study, Easy Assembly, Rustic Brown and Black BF07WJ01
8 OLIXIS 7 Drawer Mobile File Cabinet Under Desk Storage Organization with Wheels Vertical Filing Chest Rolling Wood Small Desk Printer Stand for Home Office, 15.75"D x 18.74"W x 34.25"H, White

OLIXIS 7 Drawer Mobile File Cabinet Under Desk Storage Organization with Wheels Vertical Filing Chest Rolling Wood Small Desk Printer Stand for Home Office, 15.75"D x 18.74"W x 34.25"H, White

  • SPACIOUS 7-DRAWER DESIGN: DECLUTTER WITH VERSATILE, AMPLE STORAGE SPACE.
  • QUIET, EFFORTLESS MOVEMENT: ENJOY NOISELESS DRAWERS FOR A PEACEFUL WORKSPACE.
  • DURABLE & MOBILE: STURDY BUILD WITH SMOOTH CASTERS FOR EASY RELOCATION.
BUY & SAVE
$69.97 $89.99
Save 22%
OLIXIS 7 Drawer Mobile File Cabinet Under Desk Storage Organization with Wheels Vertical Filing Chest Rolling Wood Small Desk Printer Stand for Home Office, 15.75"D x 18.74"W x 34.25"H, White
9 Sbanmao 4 Drawer Rolling File Cart with Wheels, Mobile Filing Cabinet for Home Office, Hanging File Organizer, Under Desk Storage, Multifunctional Utility Cart Printer Stand, White (Patent Pending)

Sbanmao 4 Drawer Rolling File Cart with Wheels, Mobile Filing Cabinet for Home Office, Hanging File Organizer, Under Desk Storage, Multifunctional Utility Cart Printer Stand, White (Patent Pending)

  • MAXIMIZE SPACE WITH A VERSATILE CART FOR OFFICE AND CRAFTS!
  • ORGANIZE DOCUMENTS EFFICIENTLY WITH HANGING LETTER-SIZE FILES!
  • EASILY MOVE OR SECURE YOUR STORAGE WITH WHEELS AND FIXED FEET!
BUY & SAVE
$59.99
Sbanmao 4 Drawer Rolling File Cart with Wheels, Mobile Filing Cabinet for Home Office, Hanging File Organizer, Under Desk Storage, Multifunctional Utility Cart Printer Stand, White (Patent Pending)
10 DUMOS Lateral File Cabinet with 3 Drawers Rolling Filing Cabinets Under Desk Storage Printer Stand Wood Organizer with Wheels Adjustable Shelf for Office Home Small Space, Brown

DUMOS Lateral File Cabinet with 3 Drawers Rolling Filing Cabinets Under Desk Storage Printer Stand Wood Organizer with Wheels Adjustable Shelf for Office Home Small Space, Brown

  • VERSATILE DESIGN: COMBINES OPEN SHELVES AND DRAWERS FOR OPTIMAL ORGANIZATION.
  • DURABLE & STABLE: SUPPORTS UP TO 330 LBS WITH A LONG-LASTING FINISH.
  • SMOOTH OPERATION: EASY-GLIDE DRAWERS ENHANCE EFFICIENCY AND ACCESS.
BUY & SAVE
$65.89 $69.99
Save 6%
DUMOS Lateral File Cabinet with 3 Drawers Rolling Filing Cabinets Under Desk Storage Printer Stand Wood Organizer with Wheels Adjustable Shelf for Office Home Small Space, Brown
+
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.