资产更新的图像文件夹没有显示在启动应用程序应用程序、文件夹、图像、资产

2023-09-05 08:40:50 作者:SHINEE

是有可能更新资产文件夹app.I的每次更新交了白卷应用程序,它具有对图像的资产folder.Number上的图像文件夹显示当我启动app.But当我更新资产文件夹的图像说从10-20的图像可在应用程序显示的图像的实际总数是20,但我还是看到10 images.But当我卸载并安装应用程序,我看到所有的20 images.how更新的资产文件夹无需卸载应用程序?

 的String [] getImagesFromAssets(){
    的String [] img_files = NULL;

    尝试 {
        img_files = getAssets()列表(图片)。
    }赶上(IOException异常前){
        Logger.getLogger(GameActivity.class
                。.getName())日志(Level.SEVERE,空,前);
    }
    返回img_files;
}

无效的LoadImage(字符串名称){
    尝试 {
        InputStream的IMS = getAssets()开(图片/+名)。

        绘制对象D = Drawable.createFromStream(IMS,NULL);
        image.setImageDrawable(四);

    }赶上(IOException异常前){
        返回;
    }
}
 

解决方案

Android应用程序的AFAIK Assets文件夹将在安装的时候只初始化一次。该应用程序已被打包并安装后,您将无法更新资产文件夹。安装完毕后,如果你做的资源的任何更改也不会反映到您的旧安装version.As资产的文件夹是只读的,你不能写或更新的任何文件present那里。

如果您希望得到更新它,你需要卸载旧版本并安装新版本。

文件的应用程序打不开 文件夹可以打开 是怎么回事

is it possible to update assets folder on every update of app.I make a quiz app and it has images on assets folder.Number of images on folder shows when i launch the app.But when i update images on assets folder say from 10-20 images the actual total number of images to be shown on app is 20 but i still see 10 images.But when i uninstall and install app i do see all 20 images.how to updated assets folder without uninstalling app?

String[] getImagesFromAssets() {
    String[] img_files = null;

    try {
        img_files = getAssets().list("pictures");
    } catch (IOException ex) {
        Logger.getLogger(GameActivity.class
                .getName()).log(Level.SEVERE, null, ex);
    }
    return img_files;
}

void loadImage(String name) {
    try {
        InputStream ims = getAssets().open("pictures/" + name);

        Drawable d = Drawable.createFromStream(ims, null);
        image.setImageDrawable(d);

    } catch (IOException ex) {
        return;
    }
}

解决方案

AFAIK Assets folder of android application will be initialized once at the time of installation only. You cannot update the assets folder after the application has been packaged and installed. After installation if you do any changes in the resources it will not reflect to your older installed version.As Asset folder is read only , you cannot write or update any file present there.

If you want to update it then you need to uninstall the older version and install new version.