database - How to Store Files Privately in Local Storage for App-Only Access in Flutter? - Stack Overflow

admin2025-04-18  2

I want to create a local blob storage system where I can upload files, and they will be stored in a location inaccessible to file pickers and the gallery—only my app should have access to them.

I initially tried using SQLite to store the files, but it didn’t work as expected. Ideally, I need a solution that ensures:

  • The files are stored securely on the device.
  • They remain hidden from other apps, file explorers, and media pickers.
  • Only my app can access and retrieve these files when needed.

What would be the best approach to achieve this? Are there any specific databases, file storage mechanisms, or encryption techniques I should consider?

Any guidance or code examples would be greatly appreciated!

I want to create a local blob storage system where I can upload files, and they will be stored in a location inaccessible to file pickers and the gallery—only my app should have access to them.

I initially tried using SQLite to store the files, but it didn’t work as expected. Ideally, I need a solution that ensures:

  • The files are stored securely on the device.
  • They remain hidden from other apps, file explorers, and media pickers.
  • Only my app can access and retrieve these files when needed.

What would be the best approach to achieve this? Are there any specific databases, file storage mechanisms, or encryption techniques I should consider?

Any guidance or code examples would be greatly appreciated!

Share asked Jan 30 at 12:48 Anshuman SharmaAnshuman Sharma 258 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

Files stored in internal storage (context.getFilesDir()) are only accessible to your app by default. Other apps (including file explorers and media pickers) cannot access them.

File file = new File(context.getFilesDir(), "secure_blob.dat");
FileOutputStream fos = new FileOutputStream(file);
fos.write(fileData);
fos.close();
转载请注明原文地址:http://anycun.com/QandA/1744918418a89468.html