app/src/main/java/fi/finwe/orion360/sdk/pro/examples/MainMenu.java
private boolean copyAssetToFileIfNotExist(String assetPath, String filePath) {
		boolean success = false;

		File file = new File(filePath);
		if (!file.exists()) {
			Log.i(TAG, "Copying " + assetPath + " to " + filePath);

			// Create directories.
			if (file.getParentFile().mkdirs()) {
				Log.i(TAG, "Created directory " + file.getParentFile().getAbsolutePath());
			}

			InputStream in = null;
			OutputStream out = null;
			try {
				if (file.createNewFile()) {
					Log.i(TAG, "Created file " + file.getName());
				}
				in = getAssets().open(assetPath);
				out = new FileOutputStream(file);

				// Copy the file.
				copyFile(in, out);
				Log.i(TAG, "Copied file contents from " + assetPath + " to " + filePath);
				success = true;

			} catch (IOException e) {
				Log.e(TAG, "Failed to copy " + assetPath + " to " + filePath, e);
			} finally {
				if (in != null) {
					try {
						in.close();
					} catch (IOException e) {
						Log.e(TAG, "Failed to close input file stream", e);
					}
				}
				if (out != null) {
					try {
						out.close();
					} catch (IOException e) {
						Log.e(TAG, "Failed to close output file stream", e);
					}
				}
			}
		}

		return success;
	}
/**
	 * Copy given asset file to a given file path, unless target file already exists.
	 *
	 * Missing directories will be automatically created.
	 *
	 * Note: This only works for files that have not been compressed when building the apk.
	 * Typically OK for media files, which have their own compression.
	 *
	 * @param assetPath The asset path where from to copy.
	 * @param filePath The file path where to to copy.
	 * @return true if file was copied, else false.
	 */
Copy given asset file to a given file path, unless target file already exists.
Missing directories will be automatically created.

This only works for files that have not been compressed when building the apk.
Typically OK for media files, which have their own compression.

@param assetPath The asset path where from to copy.
@param filePath The file path where to to copy.
@return true if file was copied, else false.
Copy given asset file to a given file path unless target file already exists . Missing directories will be automatically created . This only works for files that have not been compressed when building the apk . Typically OK for media files which have their own compression . @param assetPath The asset path where from to copy . @param filePath The file path where to to copy . @return true if file was copied else false .
private boolean copyAssetToFileIfNotExist(String assetPath, String filePath) {
		boolean success = false;
		File file = new File(filePath);
		if (!file.exists()) {
			Log.i(TAG, "Copying " + assetPath + " to " + filePath);
			if (file.getParentFile().mkdirs()) {
				Log.i(TAG, "Created directory " + file.getParentFile().getAbsolutePath());
			}
			InputStream in = null;
			OutputStream out = null;
			try {
				if (file.createNewFile()) {
					Log.i(TAG, "Created file " + file.getName());
				}
				in = getAssets().open(assetPath);
				out = new FileOutputStream(file);
				copyFile(in, out);
				Log.i(TAG, "Copied file contents from " + assetPath + " to " + filePath);
				success = true;
			} catch (IOException e) {
				Log.e(TAG, "Failed to copy " + assetPath + " to " + filePath, e);
			} finally {
				if (in != null) {
					try {
						in.close();
					} catch (IOException e) {
						Log.e(TAG, "Failed to close input file stream", e);
					}
				}
				if (out != null) {
					try {
						out.close();
					} catch (IOException e) {
						Log.e(TAG, "Failed to close output file stream", e);
					}
				}
			}
		}
		return success;
	}
private boolean copyAssetToFileIfNotExist ( String assetPath , String filePath ) { boolean success = false ; File file = new File ( filePath ) ; if ( ! file . exists ( ) ) { Log . i ( TAG , "Copying " + assetPath + " to " + filePath ) ; if ( file . getParentFile ( ) . mkdirs ( ) ) { Log . i ( TAG , "Created directory " + file . getParentFile ( ) . getAbsolutePath ( ) ) ; } InputStream in = null ; OutputStream out = null ; try { if ( file . createNewFile ( ) ) { Log . i ( TAG , "Created file " + file . getName ( ) ) ; } in = getAssets ( ) . open ( assetPath ) ; out = new FileOutputStream ( file ) ; copyFile ( in , out ) ; Log . i ( TAG , "Copied file contents from " + assetPath + " to " + filePath ) ; success = true ; } catch ( IOException e ) { Log . e ( TAG , "Failed to copy " + assetPath + " to " + filePath , e ) ; } finally { if ( in != null ) { try { in . close ( ) ; } catch ( IOException e ) { Log . e ( TAG , "Failed to close input file stream" , e ) ; } } if ( out != null ) { try { out . close ( ) ; } catch ( IOException e ) { Log . e ( TAG , "Failed to close output file stream" , e ) ; } } } } return success ; }
Copy given asset file to a given file path, unless target file already exists.
Copy given asset file to a given file path unless target file already exists .
// Create directories. // Copy the file.