I am developing an E-commerce application. Here I need to show lots of product images when the app is up. I have stored few product images in the drawable folder to reduce the network usage. I am planning to download delta product images when the new product is added in my back end product inventory and save it in SQLite database.
In the app I have to refer two different path ( drawable and SQLite database) to get all product images.
So how can I move the initial fish images in drawable folder to SQLite database at the time of APK generation OR after the app installation (in onCreate method of my MainActivity). And I also need to delete those initial images in the drawable folder after moving it to SQLite database.
Any suggestions are appreciated. Thank you in advance.
The bottom line is that if you deliver with content bound into your APK, it will remain there. Assuming you're planning on distributing through the Google Play store, the only way to modify this via an app update, which is obviously extremely hacky. So if your goal is to discard initial drawable resources, you cannot do this.
My advice is to compress the images as much as possible and only provide one image size which you can resize at runtime, so use the nodpi drawable resource folder (i.e. drawable-nodpi)
The alternative is to download the images via network. Though you say you don't want to do that the file sizes can be made quite small and so the download fast in most cases, so unless you're sure network connectivity will be a problem for your users it's a viable option.
Related
So I have a directory in my RPI-4 which there are various subfolders each of which contains images related to the folder.
I am making an android app which is basiclly a wallpaper folder and I have no clue how to access those images the only method i have in my mind is converting the images to base 64 then having a postgress database to access it but it seems a hassle to convert all the image and then also maintain and update it(as the app will also have a update feature later).
So i am open to learn new stuff in order to find an effective way to solve this.
Lets consider the following, I have an app with several dozen photos I want to show the user at any given time.
Right now I'm creating multiple files for each image, sizing them for different screen sizes and storing them in their respective drawable folders.
It's increasing the size of my app dramatically.
So here is my question: Is it possible to store the images on a server and use an image library like Picasso, Fresco or something else (open to anything) to fetch that image and scale it down for the device it's running on without risking running out of memory?
I'm worried that fetching a large image, loading it into memory and then resizing it will cause the same problem as trying to display it on older devices with little memory available to them.
You can write methods to request different images sizes from your server based on client info. Just write a method to measure the screen size and then request the appropriate image based on a URL endpoint (like http://myimageserver.com/images/ldpi/image1.png).
You can do optimization post-download, such as scaling, before saving the image to a local file store.
Using a reputable image loading library is a valid method (my own favourite is Glide).
The answer to your question really depends on the number of images you want to show! If there are lots, then yes storing them on a server is probably best, but also the most time-consuming and expensive (both in time and money).
Your other (easier) option is to keep the originals in the assets folder, and use your image loader to scale and load them for you. The correct path for an image in your assets folder is file:///android_asset/your_image_here.jpg. This way, you're only keeping one version of each photo in your apk and they'll load much faster.
Good day, I have a requirement to create a kind of book app with pdfs, images and videos worth up to 10gb and more on a tablet locally. Now there is no intention to sell it on the android market or any other store, its completely in house, so i think issue with apk size has been clarified. What am asking is, where is the best place to put all this contents so that i can readily load them up and use them accordingly?
Should i be using the raw folder and create sub-folders for each images, videos and pdfs?
Should i create folders on an sdcard(assuming there is one in place)? or
Please if you have any other solution or ideas on how to implement this, I would gladly like to hear this. Thanks for your responses in advance.
P.S by the way, since its a tablet specific app, is there any need to have a multi-pane layout fragment or ii can just use all the space. thank you
I suppose you can use a RAW folder, but it would also make the APK size huge from what I understand because all the files in the RAW folder need to be packaged with the application.
From what I've seen in the past, most applications, actually most games, that have lots of extra data will download the additional data on first launch. Basically:
The application launches
It checks whether or not you have all the additional data (Books, pdfs, images)
If not, it starts downloading that data to the SDCARD.
It may not make sense in your situation, but doing it this way gives you more finite control over how much data needs to be downloaded. If function A only requires package A of additional data, then you only need to download package A, you don't need to download everything. Or perhaps you could let the user choose what packages of additional data they want to download, which would also save bandwidth, time and resources.
I have an android application that allows users to upload images to their account. Im storing the images as longblob files in a mysql db and pulling them from that but I have read on here and other places that its more efficient to store your images in a file system. I know it will work for my alpha to show but its already sucking up space in the db.
Ive seen plenty of people on here and other places mentioning file systems over using a db however....no one makes any references to specific file system software or set ups. Ideally I need a system that would allow for the fastest retrieval of images from it and it has to work with a query from php.
Any tips on the matter would be awesome :)
You could store the images on the file system, and use the database to keep a file-pointer, which is simply the path to the location of the image on your system. Then, use a query to fetch the location, and use that as you would for any image.
This thread on DaniWeb shows how uploads could be handled:
http://www.daniweb.com/web-development/php/threads/162230
Also, use relative paths in case you wish to move the location of the images in the future, as mentioned in the chosen answer here:
When storing Images in the File System, Use relative paths or absolute paths?
fellow programmers! I'm new... hope you can help!
So. I'm currently developing an application that allows users to choose four different images from a set of images that I have saved in my res/drawable/ folder, and then save those choices as an entry in a database.However, I then need to be able to redisplay those four images when the user asks for them, and I'm not sure what the best way of storing the images is since my current setup isn't going to work for me in the future.
Right now, I have it working so that I actually insert the R.java int identifiers into the database for each of the images, so the database has four columns: img1(int), img2(int), img3 (int), img4 (int). Then when I write a query, I just use those values in place of R.drawable.someImage.
It works fine. Except... when I add new images to my res/drawable folder, all of the drawable ids get changed! Then the ids I have in the database are wrong, and some pull up the wrong images, and some throw NullPointerExceptions!
This is a problem, because I want to be able to update the app with new images after the users download it. How should I be storing these images so that they can be dynamically chosen, but then be reliably be referenced again?
This is a problem, because I want to be able to update the app with new images after the users download it.
I don't quite understand this - if you are going to distribute new images 'after' the users download your app then the new images are never going to have resource ids (as found in R.java) as these are auto-generated as part of the build process.
Do you really mean this or do you intend to update the app with new images and have the users download it again?
If you are going to update the app with new images periodically and have the users download the updated app, you can find the resource id at runtime using...
int resId = getResources.getIdentifier("img1", "drawable", "com.mycompany.mypackagename");
At this point, of course, you'll need to know the names of all the drawables although this could be achieved with a string array in your res/values/strings.xml.
If, however, you want to add new images without the need for the user updating the app, I'd think about maintaining an image directory (on the SD card for example). This way, you would simply just need to store the path to the image files in the DB.
Resources can be accessed as raw data: use AssetManager.open(..) Then you can use BitmapFactory.decodeStream(..) to create a Bitmap from the data stream.
So you can just save filenames of images and instantiate Bitmaps via above commands.