pub struct PrivateStorage<'a, R: Runtime> { /* private fields */ }Expand description
API of file storage intended for the app’s use only.
§Examples
fn example(app: &tauri::AppHandle) {
use tauri_plugin_android_fs::AndroidFsExt as _;
let api = app.android_fs();
let private_storage = api.private_storage();
}Implementations§
Source§impl<'a, R: Runtime> SyncPrivateStorage<'a, R>
impl<'a, R: Runtime> SyncPrivateStorage<'a, R>
Sourcepub fn resolve_path(&self, dir: PrivateDir) -> Result<PathBuf>
pub fn resolve_path(&self, dir: PrivateDir) -> Result<PathBuf>
Get an absolute path of the app-specific directory on the internal storage.
App can fully manage entries within this directory via std::fs and etc.
This function does not create any directories; it only constructs the path.
Since these locations may contain files created by other Tauri plugins or webview systems, it is recommended to add a subdirectory with a unique name.
These entries will be deleted when the app is uninstalled and may also be deleted at the user’s initialising request.
When using PrivateDir::Cache, the system will automatically delete entries as disk space is needed elsewhere on the device.
But you should not rely on this. The cache should be explicitly cleared by yourself.
The system prevents other apps and user from accessing these locations. In cases where the device is rooted or the user has special permissions, the user may be able to access this.
Since the returned paths can change when the app is moved to an adopted storage, only relative paths should be stored.
§Note
This provides a separate area for each user in a multi-user environment.
§Support
All Android version.
Sourcepub fn resolve_uri(
&self,
dir: PrivateDir,
relative_path: impl AsRef<Path>,
) -> Result<FileUri>
pub fn resolve_uri( &self, dir: PrivateDir, relative_path: impl AsRef<Path>, ) -> Result<FileUri>
Sourcepub fn create_new_temp_file(&self) -> Result<(File, PathBuf, FileUri)>
pub fn create_new_temp_file(&self) -> Result<(File, PathBuf, FileUri)>
Creates a new temporary file and returns its file, path, and URI.
App can fully manage it via std::fs and etc.
This file remains valid until the application exits.
It will be deleted when the application starts,
and may be deleted when the application exits.
§Inner
The file will be placed in the pluginAndroidFs-tempDir-01K486FKQ2BZSBGFD34RFH9FWJ
directory inside PrivateStorage::resolve_path with PrivateDir::NoBackupData.
It directory will be deleted by this plugin when the application starts,
and may be deleted when the application exits.
§Support
All Android version.
Sourcepub fn create_new_temp_file_with_guard(
&self,
) -> Result<(File, TempFileGuard, PathBuf, FileUri)>
pub fn create_new_temp_file_with_guard( &self, ) -> Result<(File, TempFileGuard, PathBuf, FileUri)>
Creates a new temporary file and returns its file,
a guard that removes the file on drop, the file path, and its URI.
App can fully manage it via std::fs and etc.
This file remains valid until the application exits.
It will be deleted when the application starts,
and may be deleted when the application exits.
§Inner
The file will be placed in the pluginAndroidFs-tempDir-01K486FKQ2BZSBGFD34RFH9FWJ
directory inside PrivateStorage::resolve_path with PrivateDir::NoBackupData.
It directory will be deleted by this plugin when the application starts,
and may be deleted when the application exits.
§Support
All Android version.
Sourcepub fn remove_all_temp_files(&self) -> Result<()>
pub fn remove_all_temp_files(&self) -> Result<()>
Removes all temporary files.
See PrivateStorage::create_new_temp_file.
§Support
All Android version.