当前位置: 首页>>代码示例>>Java>>正文


Java Context.getFilesDir方法代码示例

本文整理汇总了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;
}
 
开发者ID:Datatellit,项目名称:xlight_android_native,代码行数:23,代码来源:PictureUtils.java

示例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 + "/";
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:13,代码来源:m.java

示例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();
        }
    }
}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:18,代码来源:MapUtils.java

示例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);
}
 
开发者ID:TrustWallet,项目名称:trust-wallet-android,代码行数:9,代码来源:WalletRepoTest.java

示例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);
    }
}
 
开发者ID:redleaf2002,项目名称:downloadmanager,代码行数:24,代码来源:Helpers.java

示例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;
}
 
开发者ID:Nik-Gleb,项目名称:mpeg-encoder,代码行数:10,代码来源:MpegEncoderAndroidTest.java

示例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";

}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:22,代码来源:WXSoInstallMgrSdk.java

示例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();
    }
}
 
开发者ID:morogoku,项目名称:MTweaks-KernelAdiutorMOD,代码行数:13,代码来源:Settings.java

示例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);
}
 
开发者ID:google,项目名称:spline,代码行数:16,代码来源:PickerViewModel.java

示例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;
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:9,代码来源:PreKeyUtil.java

示例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();
}
 
开发者ID:manuelsc,项目名称:Lunary-Ethereum-Wallet,代码行数:9,代码来源:AddressNameConverter.java

示例12: getImagesDir

import android.content.Context; //导入方法依赖的package包/类
private static File getImagesDir(Context context) {
    return new File(context.getFilesDir(), IMAGE_DIRECTORY);
}
 
开发者ID:suomenriistakeskus,项目名称:oma-riista-android,代码行数:4,代码来源:ImageUtils.java

示例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);
}
 
开发者ID:sergeychilingaryan,项目名称:AOSP-Kayboard-7.1.2,代码行数:6,代码来源:ExpandableBinaryDictionary.java

示例14: Profiles

import android.content.Context; //导入方法依赖的package包/类
public Profiles(Context context) {
    super(context.getFilesDir() + "/profiles.json", VERSION);
}
 
开发者ID:AyushR1,项目名称:KernelAdiutor-Mod,代码行数:4,代码来源:Profiles.java

示例15: ImageUtils

import android.content.Context; //导入方法依赖的package包/类
private ImageUtils(Context c) {
    iconDirectory = c.getFilesDir();
    materialDesignIcons = new MaterialDesignIconsUtils(iconDirectory, httpClient);
}
 
开发者ID:Maxr1998,项目名称:home-assistant-Android,代码行数:5,代码来源:ImageUtils.java


注:本文中的android.content.Context.getFilesDir方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。