|
|
|
@ -2,6 +2,7 @@ package com.jme3.system.android; |
|
|
|
|
|
|
|
|
|
import android.app.Activity; |
|
|
|
|
import android.content.res.Resources; |
|
|
|
|
import android.os.Environment; |
|
|
|
|
import com.jme3.asset.AndroidAssetManager; |
|
|
|
|
import com.jme3.asset.AssetManager; |
|
|
|
|
import com.jme3.audio.AudioRenderer; |
|
|
|
@ -13,6 +14,7 @@ import com.jme3.system.JmeSystemDelegate; |
|
|
|
|
import com.jme3.system.Platform; |
|
|
|
|
import com.jme3.util.AndroidLogHandler; |
|
|
|
|
import com.jme3.util.JmeFormatter; |
|
|
|
|
import java.io.File; |
|
|
|
|
import java.net.URL; |
|
|
|
|
import java.util.logging.Handler; |
|
|
|
|
import java.util.logging.Level; |
|
|
|
@ -86,6 +88,34 @@ public class JmeAndroidSystem extends JmeSystemDelegate{ |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public synchronized File getStorageFolder() { |
|
|
|
|
//http://developer.android.com/reference/android/content/Context.html#getExternalFilesDir
|
|
|
|
|
//http://developer.android.com/guide/topics/data/data-storage.html
|
|
|
|
|
|
|
|
|
|
boolean mExternalStorageWriteable = false; |
|
|
|
|
String state = Environment.getExternalStorageState(); |
|
|
|
|
if (Environment.MEDIA_MOUNTED.equals(state)) { |
|
|
|
|
mExternalStorageWriteable = true; |
|
|
|
|
} else { |
|
|
|
|
mExternalStorageWriteable = false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (mExternalStorageWriteable) { |
|
|
|
|
//getExternalFilesDir automatically creates the directory if necessary.
|
|
|
|
|
//directory structure should be: /mnt/sdcard/Android/data/<packagename>/files
|
|
|
|
|
//when created this way, the directory is automatically removed by the Android
|
|
|
|
|
// system when the app is uninstalled
|
|
|
|
|
storageFolder = activity.getApplicationContext().getExternalFilesDir(null); |
|
|
|
|
logger.log(Level.INFO, "Storage Folder Path: {0}", storageFolder.getAbsolutePath()); |
|
|
|
|
|
|
|
|
|
return storageFolder; |
|
|
|
|
} else { |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static void setResources(Resources res) { |
|
|
|
|
JmeAndroidSystem.res = res; |
|
|
|
|
} |
|
|
|
|