Skip to content

App file management

File path

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) 
                }
            )
        }
    }
}

Sample code

File operations

  • Using saveFile function to save file

    saveFile(File(appInternalFilesDir().path, "save.txt"))
    
  • Get the operation result

    Version 0.4.0

    val result = saveFile(File(appInternalFilesDir().path, "save.txt"))
    if(result.isSuccess){
        .. // Code
    } else {
        .. // Code
    }
    

Sample code

Build file path

Version 0.5.1

// return a/b/c
val path = FileMgr.getPath { 
    "a" f "b" f "c"
}

Sample code