I need your help with a little problem I’m finding with my app.
In my app, I use this code to copy all the contents of the asset folder, in a folder that I create myself.
File wallpaperDirectory = new File("/sdcard/Wallpaper/");
wallpaperDirectory.mkdirs();
AssetManager assetManager = getAssets();
String[] files = null;
try {
files = assetManager.list("");
} catch (IOException e) {
Log.e("tag", e.getMessage());
}
for(String filename : files) {
InputStream in = null;
OutputStream out = null;
try {
in = assetManager.open(filename);
out = new FileOutputStream("/sdcard/Wallpaper/" + filename);
copyFile(in, out);
in.close();
in = null;
out.flush();
out.close();
out = null;
} catch(Exception e) {
Log.e("tag", e.getMessage());
}
}
private void copyFile(InputStream in, OutputStream out) throws IOException {
byte[] buffer = new byte[1024];
int read;
while((read = in.read(buffer)) != -1){
out.write(buffer, 0, read);
}
}
Now I need the ‘URI to this folder (/sdcard/Wallpaper/), that i have created, as you get? thank you very much
Get Uri of Particular Folder on SDcard.
Or