當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。