I want to load different cubemaps from database. Following code I used, but it is not working. It crashes every time. I can t get the path to the primary external storage in Android. Does anyone know how I can store Data from Database to the native GearVR Framework?
public class SampleActivity extends GVRActivity {
final File externalFilesDir = getExternalFilesDir(null);
private SampleMain main;
private long lastDownTime = 0;
//ref to storage firebase
private StorageReference cubemap_ref;
@Override
protected void onCreate(Bundle icicle) {
FirebaseStorage storage = FirebaseStorage.getInstance();
StorageReference storageRef = storage.getReference();
cubemap_ref = storageRef.child("cubemaps/cubemap_example.zip");
final long TEN_MEGABYTE = 1024 * 1024 * 10;
cubemap_ref.getBytes(TEN_MEGABYTE).addOnSuccessListener(new OnSuccessListener<byte[]>() {
@Override
public void onSuccess(byte[] bytes) {
File file = new File(externalFilesDir.getAbsolutePath(), "cubemap.zip");
try {
OutputStream os = new FileOutputStream(file);
os.write(bytes);
os.close();
} catch (IOException e) {
android.util.Log.w("ExternalStorage", "Error writing " + file, e);
}
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(Exception exception) {
// Handle any errors
}
});
super.onCreate(icicle);
main = new SampleMain(this);
setMain(main, "gvr.xml");
}
}
Thanks in advance.
I don t know why, but this code works now.