Code example for File

Methods: getPath, mkdirs

0
    private static final boolean localLOGV = true;
    public static final String TAG = "PackageManagerSettingsTests";
    protected final String PREFIX = "android.content.pm";
 
    private void writeFile(File file, byte[] data) {
        file.mkdirs();
        try { 
            AtomicFile aFile = new AtomicFile(file);
            FileOutputStream fos = aFile.startWrite();
            fos.write(data);
            aFile.finishWrite(fos);
        } catch (IOException ioe) {
            Log.e(TAG, "Cannot write file " + file.getPath());
        } 
    } 
 
    private void writePackagesXml() { 
        writeFile(new File(getContext().getFilesDir(), "system/packages.xml"),
                ("<?xml version='1.0' encoding='utf-8' standalone='yes' ?>" 
                + "<packages>" 
                + "<last-platform-version internal=\"15\" external=\"0\" />" 
                + "<permission-trees>" 
                + "<item name=\"com.google.android.permtree\" package=\"com.google.android.permpackage\" />"