Anshuman Sharma
Anshuman Sharma

Reputation: 17

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

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:

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!

Upvotes: 0

Views: 17

Answers (1)

Mir Injamamul
Mir Injamamul

Reputation: 147

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();

Upvotes: 0

Related Questions