app/src/main/java/fi/finwe/orion360/sdk/pro/examples/MainMenu.java
boolean createExpansionPackageIfNotFound() {

		if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {

			// Build the full path to the app's main expansion file.
			File root = Environment.getExternalStorageDirectory();
			File expPath = new File(root.toString() + EXPANSION_PACKAGES_PATH + getPackageName());

			// Create missing directories, if any.
			if (expPath.mkdirs()) {
				Log.i(TAG, "Created directory for expansion packages: " + expPath);
			}

			// Create main expansion filename using current package version name.
			int mainVersion;
			try {
				mainVersion = getPackageManager().getPackageInfo(getPackageName(), 0).versionCode;
			} catch (PackageManager.NameNotFoundException e) {
				Log.e(TAG, "Failed to find own package version number");
				return false;
			}
			String mainExpFilename = expPath + File.separator + "main." + mainVersion + "." +
					getPackageName() + ".obb";

			// Check if the main expansion file exists, and create it, if not.
			File mainExpFile = new File(mainExpFilename);
			if (mainExpFile.exists()) {
				Log.i(TAG, "Main expansion package found from: " + mainExpFilename);
			} else {
				if (zip(mainExpFilename, false, // do not compress media files again
						PRIVATE_EXTERNAL_FILES_PATH + TEST_VIDEO_FILE_MQ,
						PRIVATE_EXTERNAL_FILES_PATH + TEST_IMAGE_FILE_MQ)) {
					Log.i(TAG, "Created main expansion file: " + mainExpFilename);
					return true;
				} else {
					Log.i(TAG, "Failed to create main expansion file: " + mainExpFilename);
				}
			}

		} else {
			Log.e(TAG, "Media not mounted, cannot find/create expansion package");
		}

		return false;
	}
/**
	 * Check if an expansion package can be found, and if not, create one.
	 *
	 * @return true if the expansion package was created, else false.
	 */
Check if an expansion package can be found, and if not, create one.
@return true if the expansion package was created, else false.
Check if an expansion package can be found and if not create one . @return true if the expansion package was created else false .
boolean createExpansionPackageIfNotFound() {
		if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
			File root = Environment.getExternalStorageDirectory();
			File expPath = new File(root.toString() + EXPANSION_PACKAGES_PATH + getPackageName());
			if (expPath.mkdirs()) {
				Log.i(TAG, "Created directory for expansion packages: " + expPath);
			}
			int mainVersion;
			try {
				mainVersion = getPackageManager().getPackageInfo(getPackageName(), 0).versionCode;
			} catch (PackageManager.NameNotFoundException e) {
				Log.e(TAG, "Failed to find own package version number");
				return false;
			}
			String mainExpFilename = expPath + File.separator + "main." + mainVersion + "." +
					getPackageName() + ".obb";
			File mainExpFile = new File(mainExpFilename);
			if (mainExpFile.exists()) {
				Log.i(TAG, "Main expansion package found from: " + mainExpFilename);
			} else {
				if (zip(mainExpFilename, false, 
						PRIVATE_EXTERNAL_FILES_PATH + TEST_VIDEO_FILE_MQ,
						PRIVATE_EXTERNAL_FILES_PATH + TEST_IMAGE_FILE_MQ)) {
					Log.i(TAG, "Created main expansion file: " + mainExpFilename);
					return true;
				} else {
					Log.i(TAG, "Failed to create main expansion file: " + mainExpFilename);
				}
			}
		} else {
			Log.e(TAG, "Media not mounted, cannot find/create expansion package");
		}
		return false;
	}
boolean createExpansionPackageIfNotFound ( ) { if ( Environment . getExternalStorageState ( ) . equals ( Environment . MEDIA_MOUNTED ) ) { File root = Environment . getExternalStorageDirectory ( ) ; File expPath = new File ( root . toString ( ) + EXPANSION_PACKAGES_PATH + getPackageName ( ) ) ; if ( expPath . mkdirs ( ) ) { Log . i ( TAG , "Created directory for expansion packages: " + expPath ) ; } int mainVersion ; try { mainVersion = getPackageManager ( ) . getPackageInfo ( getPackageName ( ) , 0 ) . versionCode ; } catch ( PackageManager . NameNotFoundException e ) { Log . e ( TAG , "Failed to find own package version number" ) ; return false ; } String mainExpFilename = expPath + File . separator + "main." + mainVersion + "." + getPackageName ( ) + ".obb" ; File mainExpFile = new File ( mainExpFilename ) ; if ( mainExpFile . exists ( ) ) { Log . i ( TAG , "Main expansion package found from: " + mainExpFilename ) ; } else { if ( zip ( mainExpFilename , false , PRIVATE_EXTERNAL_FILES_PATH + TEST_VIDEO_FILE_MQ , PRIVATE_EXTERNAL_FILES_PATH + TEST_IMAGE_FILE_MQ ) ) { Log . i ( TAG , "Created main expansion file: " + mainExpFilename ) ; return true ; } else { Log . i ( TAG , "Failed to create main expansion file: " + mainExpFilename ) ; } } } else { Log . e ( TAG , "Media not mounted, cannot find/create expansion package" ) ; } return false ; }
Check if an expansion package can be found, and if not, create one.
Check if an expansion package can be found and if not create one .
// Build the full path to the app's main expansion file. // Create missing directories, if any. // Create main expansion filename using current package version name. // Check if the main expansion file exists, and create it, if not. // do not compress media files again