How to clear Material Cache?

I can clear cache for Model and Texture , When I clear Material Cache Always return null?

//clear Model cache code:
Spatial model = assetManager.loadModel(“XXXXX.j3o”);
assetManager.deleteFromCache((ModelKey) model.getKey());

//clear Texture cache code:
Geometry geometry = (Geometry) spatial;
AssetKey key=geometry.getMaterial().getTextureParam(“DiffuseMap”).getTextureValue().getKey();
if (key != null && assetManager.getFromCache(key) != null) {
assetManager.deleteFromCache(key);
}

But I use " geometry.getMaterial().getKey() " function, Always return null,
How can i do?

My English is a little weak, please don’t mind.

Did you load a j3m?

…else that material did not come from the asset manager.

What is it that you are actually trying to do?

I have two different ogre format file.
The *.material file almost the same,
The only difference is Texture.
1550072255984

I try the following

Spatial model = assetManager.loadModel(modelPath);
BinaryExporter exporter = BinaryExporter.getInstance();
String spatialName = modelPath.substring(0, modelPath.lastIndexOf("."));
File j3ofile = new File(spatialName.concat(".j3o"));
exporter.save(model , j3ofile);

First j3o file is Ok,But the second j3o file is the first material data.

if it would be about loading, then i would say why not just change texture.

but i read your below code and i see you want to export into j3o (that i do via SDK myself)

in this case i would say: can’t you look at SDK sourcecode and see how its done there?

I know, I can call clearCache() function,Is rigth.
But i don’t want to do it.
Because total cache will be released, I just want to clear the last cache.

If that’s true then the loaded object also had the wrong values. Check it in code.

…no amount of cache clearing is going to fix that as the Material is instantiated at runtime and it’s parameters set. It was not “cached”.

I have compiled the example.
In this example, I call clearCache() function can be solved the problem.
1550114835006