本文整理了Java中android.content.Context.getDir()
方法的一些代码示例,展示了Context.getDir()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Context.getDir()
方法的具体详情如下:
包路径:android.content.Context
类名称:Context
方法名:getDir
暂无
代码示例来源:origin: oasisfeng/condom
@Override public File getDir(String name, int mode) {
return mBase.getDir(name, mode);
}
代码示例来源:origin: ACRA/acra
@NonNull
public File getApprovedFolder() {
return context.getDir(APPROVED_FOLDER_NAME, Context.MODE_PRIVATE);
}
代码示例来源:origin: ACRA/acra
@NonNull
public File getUnapprovedFolder() {
return context.getDir(UNAPPROVED_FOLDER_NAME, Context.MODE_PRIVATE);
}
代码示例来源:origin: Justson/AgentWeb
static String getDatabasesCachePath(Context context) {
return context.getApplicationContext().getDir("database", Context.MODE_PRIVATE).getPath();
}
代码示例来源:origin: yigit/android-priority-jobqueue
FileStorage(Context appContext, String id) {
this.folder = new File(appContext.getDir("com_birbit_jobqueue_jobs", Context.MODE_PRIVATE),
"files_" + id);
//noinspection ResultOfMethodCallIgnored
this.folder.mkdirs();
}
代码示例来源:origin: Marswin/MarsDaemon
private boolean install(Context context, String destDirName, String assetsDirName, String filename) {
File file = new File(context.getDir(destDirName, Context.MODE_PRIVATE), filename);
if (file.exists()) {
return true;
}
try {
copyAssets(context, (TextUtils.isEmpty(assetsDirName) ? "" : (assetsDirName + File.separator)) + filename, file, "700");
return true;
} catch (Exception e) {
return false;
}
}
代码示例来源:origin: Marswin/MarsDaemon
private boolean install(Context context, String destDirName, String assetsDirName, String filename) {
File file = new File(context.getDir(destDirName, Context.MODE_PRIVATE), filename);
if (file.exists()) {
return true;
}
try {
copyAssets(context, (TextUtils.isEmpty(assetsDirName) ? "" : (assetsDirName + File.separator)) + filename, file, "700");
return true;
} catch (Exception e) {
return false;
}
}
代码示例来源:origin: square/spoon
private static File obtainDirectory(Context context, String testClassName,
String testMethodName, String directoryName) {
File directory;
if (SDK_INT >= LOLLIPOP) {
// Use external storage.
directory = new File(getExternalStorageDirectory(), "app_" + directoryName);
} else {
// Use internal storage.
directory = context.getDir(directoryName, MODE_WORLD_READABLE);
}
File dirClass = new File(directory, testClassName);
File dirMethod = new File(dirClass, testMethodName);
createDir(dirMethod);
return dirMethod;
}
代码示例来源:origin: Marswin/MarsDaemon
public void run() {
File binaryFile = new File(context.getDir(BINARY_DEST_DIR_NAME, Context.MODE_PRIVATE), BINARY_FILE_NAME);
new NativeDaemonAPI20(context).doDaemon(
context.getPackageName(),
configs.DAEMON_ASSISTANT_CONFIG.SERVICE_NAME,
binaryFile.getAbsolutePath());
};
};
代码示例来源:origin: k9mail/k-9
public static LocalKeyStore createInstance(Context context) {
String keyStoreLocation = context.getDir("KeyStore", Context.MODE_PRIVATE).toString();
LocalKeyStore localKeyStore = new LocalKeyStore(keyStoreLocation);
localKeyStore.initializeKeyStore();
return localKeyStore;
}
代码示例来源:origin: Marswin/MarsDaemon
private boolean initIndicatorFiles(Context context){
File dirFile = context.getDir(INDICATOR_DIR_NAME, Context.MODE_PRIVATE);
if(!dirFile.exists()){
dirFile.mkdirs();
}
try {
createNewFile(dirFile, INDICATOR_PERSISTENT_FILENAME);
createNewFile(dirFile, INDICATOR_DAEMON_ASSISTANT_FILENAME);
return true;
} catch (IOException e) {
e.printStackTrace();
return false;
}
}
代码示例来源:origin: stackoverflow.com
File Path = Ctxt.getDir("Data", 0);
File DBFile = new File(Path, "database.db");
if(!DBFile.exists() || DatabaseNeedsUpgrade) //Need to copy...
CopyDatabase(Ctxt, DBFile);
static private void CopyDatabase(Context Ctxt, File DBFile) throws IOException
{
AssetManager assets = Ctxt.getAssets();
OutputStream outstream = new FileOutputStream(DBFile);
DBFile.createNewFile();
byte []b = new byte[1024];
int i, r;
String []assetfiles = assets.list("");
Arrays.sort(assetfiles);
for(i=1;i<10;i++) //I have definitely less than 10 files; you might have more
{
String partname = String.format("%d.db", i);
if(Arrays.binarySearch(assetfiles, partname) < 0) //No such file in assets - time to quit the loop
break;
InputStream instream = assets.open(partname);
while((r = instream.read(b)) != -1)
outstream.write(b, 0, r);
instream.close();
}
outstream.close();
}
代码示例来源:origin: Marswin/MarsDaemon
private boolean initIndicators(Context context){
File dirFile = context.getDir(INDICATOR_DIR_NAME, Context.MODE_PRIVATE);
if(!dirFile.exists()){
dirFile.mkdirs();
}
try {
createNewFile(dirFile, INDICATOR_PERSISTENT_FILENAME);
createNewFile(dirFile, INDICATOR_DAEMON_ASSISTANT_FILENAME);
return true;
} catch (IOException e) {
e.printStackTrace();
return false;
}
}
代码示例来源:origin: Marswin/MarsDaemon
private boolean initIndicatorFiles(Context context){
File dirFile = context.getDir(INDICATOR_DIR_NAME, Context.MODE_PRIVATE);
if(!dirFile.exists()){
dirFile.mkdirs();
}
try {
createNewFile(dirFile, INDICATOR_PERSISTENT_FILENAME);
createNewFile(dirFile, INDICATOR_DAEMON_ASSISTANT_FILENAME);
return true;
} catch (IOException e) {
e.printStackTrace();
return false;
}
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
storageFolder = view.getContext().getDir("", Context.MODE_PRIVATE);
storageFolders.put(type, storageFolder);
代码示例来源:origin: robolectric/robolectric
@Test
public void shouldCreateIfDoesNotExistAndGetApplicationDataDirectory() throws Exception {
File dataDir = new File(context.getPackageManager()
.getPackageInfo("org.robolectric", 0).applicationInfo.dataDir, "data");
assertThat(dataDir.exists()).isFalse();
dataDir = context.getDir("data", Context.MODE_PRIVATE);
assertThat(dataDir.exists()).isTrue();
}
代码示例来源:origin: robolectric/robolectric
@Test
public void shouldGetApplicationDataDirectory() throws IOException {
File dataDir = context.getDir("data", Context.MODE_PRIVATE);
assertThat(dataDir.exists()).isTrue();
}
代码示例来源:origin: koral--/android-gif-drawable
File outputFile = new File(context.getDir(LIB_DIR, Context.MODE_PRIVATE), outputFileName);
if (outputFile.isFile()) {
return outputFile;
代码示例来源:origin: JZ-Darkal/AndroidHttpCapture
webSettings.setAllowFileAccess(true);
webSettings.setDatabaseEnabled(true);
String dir = getActivity().getApplicationContext().getDir("database", Context.MODE_PRIVATE).getPath();
webSettings.setDatabasePath(dir);
webSettings.setDomStorageEnabled(true);
代码示例来源:origin: xfumihiro/ViewInspector
context.getDir(DEX_CACHE_DIRECTORY, Context.MODE_PRIVATE));
try {
return (Class<G>) classLoader.loadClass(proxyClassName);
内容来源于网络,如有侵权,请联系作者删除!