App file management¶
File path¶
As shown in the picture on the right, the corresponding file paths are displayed in sequence.
private val devicePath = listOf(
appInternalFilesDir().path,
appInternalCacheDir().path,
appExternalFilesDir(null).path,
appExternalCacheDir().path,
ImageMgr.getExternalFilesDir().path,
ImageMgr.getSharedFilesDir().path,
MusicMgr.getExternalFilesDir().path,
MusicMgr.getSharedFilesDir().path
)
@Composable
fun DevicePath(modifier: Modifier = Modifier){
LazyColumn(modifier = modifier){
items(devicePath){
ListItem(
headlineText = {
Text(text = it)
}
)
}
}
}
File operations¶
-
Using
saveFile
function to save filesaveFile(File(appInternalFilesDir().path, "save.txt"))
-
Get the operation result
val result = saveFile(File(appInternalFilesDir().path, "save.txt")) if(result.isSuccess){ .. // Code } else { .. // Code }
Build file path¶
// return a/b/c
val path = FileMgr.getPath {
"a" f "b" f "c"
}