本文整理汇总了Java中android.content.Context.getFilesDir方法的典型用法代码示例。如果您正苦于以下问题:Java Context.getFilesDir方法的具体用法?Java Context.getFilesDir怎么用?Java Context.getFilesDir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.content.Context
的用法示例。
在下文中一共展示了Context.getFilesDir方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: reverseSavePic
import android.content.Context; //导入方法依赖的package包/类
/**
* 把图片从应用内部写到sd卡上
*/
public String reverseSavePic(Context context, String orifilePath) {
try {
int byteread = 0;
File oriFile = new File(context.getFilesDir(), orifilePath);
if (oriFile.exists()) {
InputStream inStream = new FileInputStream(oriFile);
FileOutputStream fs = new FileOutputStream(initImageFile());
byte[] buffer = new byte[1444];
while ((byteread = inStream.read(buffer)) != -1) {
fs.write(buffer, 0, byteread);
}
inStream.close();
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
示例2: c
import android.content.Context; //导入方法依赖的package包/类
private static String c(Context context, String str) {
String str2 = context.getFilesDir() + a + str;
try {
File file = new File(str2);
if (!file.exists()) {
file.mkdirs();
}
} catch (Exception e) {
e.printStackTrace();
}
return str2 + "/";
}
示例3: removeUnusedTiles
import android.content.Context; //导入方法依赖的package包/类
public static void removeUnusedTiles(Context mContext, final ArrayList<String> usedTiles) {
// remove all files are stored in the tile path but are not used
File folder = new File(mContext.getFilesDir(), TILE_PATH);
File[] unused = folder.listFiles(new FilenameFilter() {
@Override
public boolean accept(File dir, String filename) {
return !usedTiles.contains(filename);
}
});
if (unused != null) {
for (File f : unused) {
f.delete();
}
}
}
示例4: setUp
import android.content.Context; //导入方法依赖的package包/类
@Before
public void setUp() {
Context context = InstrumentationRegistry.getTargetContext();
PreferenceRepositoryType preferenceRepositoryType = new SharedPreferenceRepository(context);
AccountKeystoreService accountKeystoreService = new GethKeystoreAccountService(new File(context.getFilesDir(), "store"));
EthereumNetworkRepositoryType networkRepository = new EthereumNetworkRepository(preferenceRepositoryType);
accountRepository = new WalletRepository(preferenceRepositoryType, accountKeystoreService, networkRepository);
}
示例5: getDestinationDirectory
import android.content.Context; //导入方法依赖的package包/类
private static File getDestinationDirectory(Context context, int destination, boolean running)
throws IOException {
switch (destination) {
case Downloads.Impl.DESTINATION_CACHE_PARTITION:
case Downloads.Impl.DESTINATION_CACHE_PARTITION_PURGEABLE:
case Downloads.Impl.DESTINATION_CACHE_PARTITION_NOROAMING:
if (running) {
return context.getFilesDir();
} else {
return context.getCacheDir();
}
case Downloads.Impl.DESTINATION_EXTERNAL:
final File target = new File(
Environment.getExternalStorageDirectory(), Environment.DIRECTORY_DOWNLOADS);
if (!target.isDirectory() && target.mkdirs()) {
throw new IOException("unable to create external downloads directory");
}
return target;
default:
throw new IllegalStateException("unexpected destination: " + destination);
}
}
示例6: setUp
import android.content.Context; //导入方法依赖的package包/类
/** Common "before" functionality. */
@Before
public final void setUp() throws Exception {
final Context context = InstrumentationRegistry.getContext();
final File file = new File(context.getFilesDir()/*OUTPUT_DIR*/, OUTPUT_FILE_NAME);
Assert.assertFalse(!file.createNewFile() && (!file.delete() || !file.createNewFile()));
mOutputFile = file;
}
示例7: _targetSoFile
import android.content.Context; //导入方法依赖的package包/类
/**
* Concatenate the path of the so library, including directory.
* @param libName the raw name of the lib
* @param version the version of the so library
* @return the path of the so library
*/
static String _targetSoFile(String libName, int version) {
Context context = mContext;
if (null == context) {
return "";
}
String path = "/data/data/" + context.getPackageName() + "/files";
File f = context.getFilesDir();
if (f != null) {
path = f.getPath();
}
return path + "/lib" + libName + "bk" + version + ".so";
}
示例8: Settings
import android.content.Context; //导入方法依赖的package包/类
/**
* Read the JSON file from cache
*
* @param context needed to get the cache directory
*/
public Settings(Context context) {
super(context.getFilesDir() + "/settings.json", 1);
if (Utils.existFile(context.getFilesDir() + "/commands.json", false)) {
new File(context.getFilesDir() + "/commands.json").delete();
}
}
示例9: openFile
import android.content.Context; //导入方法依赖的package包/类
public void openFile(Context context, String filename, boolean createNew) {
if (createNew) {
try {
File internalDirectory = context.getFilesDir();
File file = new File(internalDirectory.getAbsolutePath() + "/" + filename);
file.createNewFile();
addFile(file);
} catch (IOException e) {
e.printStackTrace();
}
}
Intent intent = new Intent(context, EditorActivity.class);
intent.putExtra(EditorActivity.FILENAME, filename);
context.startActivity(intent);
}
示例10: getKeysDirectory
import android.content.Context; //导入方法依赖的package包/类
private static File getKeysDirectory(Context context, String name) {
File directory = new File(context.getFilesDir(), name);
if (!directory.exists())
directory.mkdirs();
return directory;
}
示例11: load
import android.content.Context; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public synchronized void load(Context context) throws IOException, ClassNotFoundException {
FileInputStream fout = new FileInputStream(new File(context.getFilesDir(), "namedb.dat"));
ObjectInputStream oos = new ObjectInputStream(new BufferedInputStream(fout));
addressbook = (HashMap<String, String>) oos.readObject();
oos.close();
fout.close();
}
示例12: getImagesDir
import android.content.Context; //导入方法依赖的package包/类
private static File getImagesDir(Context context) {
return new File(context.getFilesDir(), IMAGE_DIRECTORY);
}
示例13: getDictFile
import android.content.Context; //导入方法依赖的package包/类
public static File getDictFile(final Context context, final String dictName,
final File dictFile) {
return (dictFile != null) ? dictFile
: new File(context.getFilesDir(), dictName + DICT_FILE_EXTENSION);
}
示例14: Profiles
import android.content.Context; //导入方法依赖的package包/类
public Profiles(Context context) {
super(context.getFilesDir() + "/profiles.json", VERSION);
}
示例15: ImageUtils
import android.content.Context; //导入方法依赖的package包/类
private ImageUtils(Context c) {
iconDirectory = c.getFilesDir();
materialDesignIcons = new MaterialDesignIconsUtils(iconDirectory, httpClient);
}