21 package com.arm.malideveloper.openglessdk.fileloading;
24 import java.io.IOException;
25 import java.io.InputStream;
26 import java.io.RandomAccessFile;
28 import android.os.Bundle;
29 import android.os.Environment;
30 import android.app.Activity;
31 import android.content.SharedPreferences;
32 import android.content.res.AssetManager;
33 import android.util.Log;
37 private String
LOGTAG =
"FirstLoading";
40 @Override
protected void onCreate(Bundle savedInstanceState)
42 super.onCreate(savedInstanceState);
44 SharedPreferences savedValues = getSharedPreferences(
"savedValues", MODE_PRIVATE);
45 int programRuns = savedValues.getInt(
"programRuns", 1);
47 Log.d(
LOGTAG,
"This application has been run " + programRuns +
" times");
50 SharedPreferences.Editor editor = savedValues.edit();
51 editor.putInt(
"programRuns", programRuns);
56 String privateAssetDirectory = getFilesDir().getAbsolutePath();
57 String publicAssetDirectory = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getAbsolutePath();
58 String cacheAssetDirectory = getCacheDir().getAbsolutePath();
60 Log.i(
LOGTAG,
"privateAssetDirectory's path is equal to: " + privateAssetDirectory);
61 Log.i(
LOGTAG,
"publicAssetDirectory's path is equal to: " + publicAssetDirectory);
62 Log.i(
LOGTAG,
"cacheAssetDirectory's path is equal to: " + cacheAssetDirectory);
66 String privateApplicationFileName =
"privateApplicationFile.txt";
67 String publicApplicationFileName =
"publicApplicationFile.txt";
68 String cacheApplicationFileName =
"cacheApplicationFile.txt";
70 extractAsset(privateApplicationFileName, privateAssetDirectory);
71 extractAsset(publicApplicationFileName, publicAssetDirectory);
72 extractAsset(cacheApplicationFileName, cacheAssetDirectory);
76 NativeLibrary.init(privateAssetDirectory +
"/" + privateApplicationFileName, publicAssetDirectory +
"/" + publicApplicationFileName, cacheAssetDirectory +
"/" + cacheApplicationFileName);
93 File fileTest =
new File(assetPath, assetName);
97 Log.d(
LOGTAG, assetName +
" already exists no extraction needed\n");
101 Log.d(
LOGTAG, assetName +
" doesn't exist extraction needed \n");
106 RandomAccessFile out =
new RandomAccessFile(fileTest,
"rw");
107 AssetManager am = getResources().getAssets();
109 InputStream inputStream = am.open(assetName);
110 byte
buffer[] =
new byte[1024];
116 count = inputStream.read(
buffer, 0, 1024);
125 Log.e(
LOGTAG,
"Failure in extractAssets(): " + e.toString() +
" " + assetPath+assetName);
127 if(fileTest.exists())
129 Log.d(
LOGTAG,
"File Extracted successfully");
GLenum GLenum GLsizei count
void extractAsset(String assetName, String assetPath)
void onCreate(Bundle savedInstanceState)