Skip to content

preLoadGameByDirectoryPath ​

Pre-load a Game (by Local Directory Path) ​

The preLoadGameByDirectoryPath method lets developers pre-load from an already-extracted game resource directory. This interface reads the raw resource files directly from the local file system, skipping the download and extraction steps, making it the fastest of all pre-load methods.

This method is typically used for developer debugging, built-in resource distribution (pre-placing the game package in the Assets/private directory and extracting it), or scenarios where the business side has already handled resource extraction management.


Method Declaration ​

java
/**
 * Pre-load a game by game directory
 *
 * @param directoryPath     Local game directory
 * @param params            Parameter object
 * @param listener          Pre-load status listener
 * @return SUDOPGameTask Task handle, used to manage or destroy the pre-load task
 */
public static SUDOPGameTask preLoadGameByDirectoryPath(String directoryPath, SUDOPGamePackageParams params, SUDOPPreLoadGameListener listener);

Parameters ​

Specifies the location of the local resource directory:

FieldTypeDescription
directoryPathStringRequired. The absolute path of the game resource folder on the device (this directory should contain core files such as app.json).

1. SUDOPGamePackageParams ​

Specifies the concrete resource download details:

FieldTypeDescription
versionStringRequired. Game version
fidStringGame package file fingerprint
fidTypeFIDTypeGame package file fingerprint generation method
appGameIDStringRequired. The specified gameID
appCPIDStringThe game developer's CP ID
appGroupIDStringThe game developer's Group ID

2. FIDType ​

Specifies the game package file fingerprint generation method

FieldTypeDescription
MD5enumMD5 algorithm
CRC32enumCRC32 algorithm
SHA1enumSHA1 algorithm
SHA256StrenumingSHA256 algorithm

4. SUDOPPreLoadGameListener ​

Callback interface that receives the pre-load result:

  • void onSuccess(String gameId, SUDRTGameHandleProvider provider): Pre-load succeeded.

  • gameId: The unique game identifier parsed from the directory configuration file.

  • provider: Call provider.getGameHandle() to obtain the game instance handle.

  • void onFailure(int retCode, String retMsg): Pre-load failed. Common causes include a nonexistent directory path, a missing core configuration file, insufficient permissions, or out of memory.


Runtime Behavior ​

  1. Structure scan: The SDK scans the specified directory to verify that the required entry file (such as app.json) and resource subdirectories exist.
  2. Environment loading: Directly establishes a file stream mapping, starts the runtime environment, and loads the script core.
  3. Resource pre-read: Reads and parses the first-screen textures, configuration, and scripts in advance according to the configuration.
  4. Instance generation: Completes all non-UI-layer initialization logic and returns a SUDRTGameHandle that is ready to use immediately.

Example Code ​

java
// 1. Prepare the local directory parameter
String directoryPath = getFilesDir().getAbsolutePath() + "/extracted_games/game_101/";

// 2. Perform pre-load
SUDOPGamePackageParams params = new SUDOPGamePackageParams();
params.version = "gamePkgVersion";
params.fid = "2e7ca170f33629c7baf4dc430c541c43";
params.fidType = FIDType.MD5;
params.appGameID = "appGameID";
params.appCPID = "Game Developer id";
params.appGroupID = "Game developer group id";
SUDOPGameTask preLoadTask = SUDOP.preLoadGameByDirectoryPath(directoryPath, params, new SUDOPPreLoadGameListener() {
    @Override
    public void onSuccess(String gameId, SUDRTGameHandleProvider provider) {
        SUDRTGameHandle handle = provider.getGameHandle();
    }
    @Override
    public void onFailure(int retCode, String retMsg) {
    }
});

// If the Activity is destroyed, remember to release the task
// preLoadTask.destroy();

Notes ​

  • Path validity: The path passed in must be a directory path, and it must end with a slash (/) or otherwise be one the SDK can correctly recognize.
  • Permission management: Make sure the App has read access to this directory.
  • Resource updates: Because the SDK does not manage resource updates under this path, if the business side replaces files in the directory, it is recommended to destroy the old task and call this interface again to reload.

The success callback returns SUDRTGameHandleProvider. Call provider.getGameHandle() to obtain the SUDRTGameHandle.