本文整理匯總了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);
}