Comments (1)
The project I'm working on is at the moment not publicly available, but this is the code which processes media folders by checking the filename. If it ends with "-media" which is the naming for the media folders it will create the folder on the sd card and copy all containing files over to the sdcard directory. This currently only works for files, not for nested directories. I can't commit this to this repo at the moment, but this is the new method copyFormMedia() and the updated method copyForms() from GeoODK.java
private void copyFormMedia(String foldername){
AssetManager assetManager = getAssets();
String[] assetList = null;
try {
assetList = assetManager.list("forms" + File.separator + foldername);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
for (String assetName : assetList) {
InputStream in = null;
OutputStream out = null;
File outFile = new File(FORMS_PATH + File.separator + foldername + File.separator + assetName);
if (!outFile.exists()) {
try {
in = assetManager.open("forms" + File.separator + foldername + File.separator + assetName);
out = new FileOutputStream(FORMS_PATH + File.separator + foldername + File.separator + assetName);
copyFile(in, out);
in.close();
out.flush();
out.close();
in = null;
out = null;
} catch (IOException e) {
Log.e("tag", "Failed to copy asset file: " + FORMS_PATH + File.separator, e);
}
}
}
}
private void copyForms(String[] forms) {
AssetManager assetManager = getAssets();
InputStream in = null;
OutputStream out = null;
for (int i = 0; forms.length > i; i++) {
String filename = forms[i];
File form_file = new File(FORMS_PATH, filename);
if (filename.endsWith("-media")) {
boolean success = true;
if (!form_file.exists()) {
success = form_file.mkdir();
}
if (!success){
Log.e("tag", "Failed to create media folder: " + FORMS_PATH + File.separator + filename);
continue;
}
copyFormMedia(filename);
} else {
if (!form_file.exists()) {
try {
in = assetManager.open("forms/" + filename);
out = new FileOutputStream(FORMS_PATH + File.separator + filename);
copyFile(in, out);
in.close();
out.flush();
out.close();
in = null;
out = null;
} catch (IOException e) {
Log.e("tag", "Failed to copy asset file: " + FORMS_PATH + File.separator + forms[i], e);
}
}
}
System.out.println(forms[i]);
}
}
from collect.
Related Issues (20)
- Images are not scaled according to pixel density of the device HOT 2
- [Feature] Show Grouped Inputs on one screen HOT 3
- [Feature] Use map input for geopoint HOT 1
- [Refactoring] createErrorDialog
- *.iml should be on .gitignore HOT 1
- [Feature] Geo Input via OpenStreetMap Features HOT 3
- hide the edit button and the delete button
- persistent bug "add point" in devops branch HOT 1
- External select causing error HOT 7
- GeoPoint Widget does not save altitude and accuracy HOT 10
- Unclosed polygons in draw widget viewed as closed
- GeoDraw Widget does not save replaced features
- GeoTrace Widget Features can not be edited or cleared
- Timestamp for geolocation in Geotrace widget
- Option or method to undo "Add Group"
- change language of user interface
- App Crashes on selecting Google as platform
- The app only works with https request
- Permission
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from collect.