Making folders of images available in the project - java

I need set of images in jpg format to be in this specific folder.
path = getFilesDir() + "/imagefiles/";
After root my mobile phone, I manage to find the specific folder. The location is /data/data/*packagename/files/imagesfile/*png images.
I can copy the image manually into the folder but i want to deploy a project that already has the image in it.
I have tried several solution but none really works for me. Please help me.

I can copy the image manually into the folder but i want to deploy a project that already has the image in it
It is not possible for you to create an app that automatically has files in getFilesDir() immediately upon installation.
What is possible is for you to put images there on the first run of your app. Those images could be:
downloaded from the Internet
packaged in assets/ in the project, then copied into your desired location using AssetManager and open()
packaged as raw resources in the project, then copied into your desired location using Resources and openRawResource()
etc.

Related

Spring boot doesn't serve some of the images from the src/main/resources/public directory

I'm trying to develop a small webapp, for learning purpose, with spring boot,thymeleaf and mysql.I'm using Eclipse IDE
Users can upload images to the app, My Controller class store the images in the src/main/resources/public/images folder and it's URL in the db.
The problem is, Eventhough the images saved by the controller exists in the src/main/resources/public/images directory, They are not directly visible in the public directory from Eclipse, as a result when referred from the served webpages, those images do not show up. Some of the images I manually copy pasted into the public/images folder within the Eclipse .(To do that actually I had to move images to another directory as it's not possible to copy from and paste into the same folder)
Those images are rendered in the served web pages.. The other images saved by the controller, even though they exists in the same directory ,they are not directly visible from Eclipse IDE and they are't rendered in the served pages.
This is Directory's view within the eclipse and all these images are rendered correctly in the served webpages
This is the same directorie's view from the file system, and it contains many images that are not directly visible from eclipse.
And when I include these images in the webpages , they are'nt rendered even though they reside in the exact same folder as other images..
How to get around this issue?
When you run a spring boot or normal spring project using IDE it will bundle everything inside a war and then it serves that bundle so without restarting the server or re-running the application Eclipse doesn't loads the images.
This has nothing to do with spring boot.It is because of the Eclipse IDE as you know if you paste one image inside the folder directory but images wont load without restarting the server or re-running the application.
My recommendation would be to store images on any directory other than your deployed folder directory and access them without any issues.
I have done this inside tomcat folder without any issue.

How to hide a folder using programmatically in android, and access there file.

I am developing android application which having some external files. I want to hide these files. Can we access hidden file in my app. Example I have many of images which will be use in my app. I want to hide these file but access only using my app.
Just put a . in front of your folder name than it becomes a hidden folder
Android is multi user linux system, so if you create folder starting with dot, it'll be hidden.
So store folder starting with dot
for example
File folder = new File(Environment.getExternalStorageDirectory(), ".hiddenFolder");
folder.mkdir();
and store all images in this folder and access images in your app from same folder.
Create a folder with a . (dot) before its name, and add an empty .nomedia file inside it. (.(dot)nomedia - exactly as I typed it) and add your files ands images there.
Now other Apps like Gallery will ignore these images. That's the only way that I think this can be done.
E.g.: folder name: .images
which includes an empty file .nomedia

Navigating a folder up?

I am wondering how I can navigate a folder up like shown here: https://github.com/libgdx/libgdx/wiki/Texture-packer#automatic-packing
I did exactly the same ../ but libgdx is registering .. as a folder and does not go up in the tree. However the docs are kinda old and might be outdated.
TexturePacker.Settings settings = new TexturePacker.Settings();
settings.maxWidth = 1024;
settings.maxHeight = 1024;
TexturePacker.process(settings, "../images",
"../android/assets/tilesets/",
"set01");
//Input file does not exist: C:\Programming\Java\LibGDX\Projects\CloneQuest\android\assets\..\images
The reason why I want this is because I want to have a image folder with all separate images outside the assets folder. Whenever the desktop application is run in it's current state it will pack the images into the assets folder. But these separate images won't be transferred to the jar or apk when making a build.
This is working, the output just prints it like this. Are you sure there is a folder images as a sibling of assets, as you can see you are in the assets folder
C:\Programming\Java\LibGDX\Projects\CloneQuest\android\assets..
Please provide your folder structure if you struggle.

how to download folder containing files(pdf,png etc) from php server in android

i want to download folder containing files like pdf,jpg,png etc from web services.I have written a application that can download pdf,png file.But i want to download folder containing several files. So my question is- is it possible to download folder and if yes then how can i download folder from server in android. thank you
If you can download one file, why wouldn't you be able to download several? Create the folder on Android, queue the files and start the next download when the current is finished, filling the folder. Also Android supports ZIP, so that might be your best call.
Folder is nothing but an FILE but a different type of file. Once you get the folder you can list down the files in it. You already have URL with the folder, u just need to append the URL of the folder to the files in it and download them one by one.

jsp file upload location

hi i am uploading my images using the
String filePath = context.getRealPath("/")+"/Library/";
all of the images are get to saved in
.../workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/MyProj/Library/
when i list the files in
.../workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/MyProj/Library/
from terminal i can see the images that were uploaded. but if i list the files in
.../workspace/MyProj/Library/
i cannot see them. also from eclipse (inside project explorer)
MyProj
->Library
i cannot see the images uploaded. then i thought probably that location is kind of temp location, and restarted my computer. but uploaded images are still in
.../workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/MyProj/Library/
but through eclipse they are not visible, doing file->refresh also did not help. my questions are follows will the uploaded images stay in this location
.../workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/MyProj/Library/
and why i cannot see them from eclipse? if it is possible can you show me how to save them directly in
.../workspace/MyProj/Library/
thanks!
You can't see the images because eclipse has deployed your webapp to a server and your images are being uploaded to the server.
You can save them directly to your workspace by using:
System.getEnv("user.home")+"/workspace/MyProj/Library/"
instead of:
context.getRealPath("/")+"/Library/";

Categories