public class StorageUtils
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static java.lang.Object |
fileRWMutex |
| Constructor and Description |
|---|
StorageUtils() |
| Modifier and Type | Method and Description |
|---|---|
static java.io.InputStream |
getInputStreamAndDelete(java.io.File file)
Get the input stream of a file and delete the file.
|
static java.io.File |
getPrivateDir(android.content.Context context,
java.lang.String dirPath)
Get the directory for the user's private directory.
|
static java.lang.String |
getPrivateRelativePath(android.content.Context context,
java.io.File file)
Get the relative path of a given file from the private directory.
|
static java.io.File |
getPublicDir(java.lang.String dirPath)
Get the directory for the public directory.
|
static java.lang.String |
getPublicRelativePath(java.io.File file)
Get the relative path of a given file from the public directory.
|
static java.lang.String |
getRelativePath(java.io.File file,
java.io.File folder)
Get the relative path from a file to a directory.
|
static java.io.File |
getValidFile(android.content.Context context,
java.lang.String filePath,
boolean isPublic)
Get a valid file of a given file path.
|
static void |
safeDelete(java.io.File file)
Delete a file without throw any exception.
|
static void |
writeToFile(java.lang.String content,
java.io.File validFile,
boolean append) |
public static java.io.File getPublicDir(java.lang.String dirPath)
dirPath - the path of dirpublic static java.lang.String getPublicRelativePath(java.io.File file)
file - the file to get pathpublic static java.lang.String getPrivateRelativePath(android.content.Context context,
java.io.File file)
file - the file to get pathpublic static java.io.File getPrivateDir(android.content.Context context,
java.lang.String dirPath)
dirPath - the path of dirpublic static java.io.File getValidFile(android.content.Context context,
java.lang.String filePath,
boolean isPublic)
context - a Context instancefilePath - the original file pathisPublic - if true, the valid path will be in external storage (sdcard);
if false, the valid path will be in internal storage.public static void writeToFile(java.lang.String content,
java.io.File validFile,
boolean append)
public static java.io.InputStream getInputStreamAndDelete(java.io.File file)
file - the file to readpublic static java.lang.String getRelativePath(java.io.File file,
java.io.File folder)
file - the file to get relative path to.folder - the directory to get relative path from.public static void safeDelete(java.io.File file)
file - the file to delete.