Download Images from server location saved in Sqlite - sqlite

I am developing a android application. In one activity I have to download multiple images associated with a List Item say 2 images per List Item. The Image URLs are saved in Sqlite DB. These images are LowRes and HighRes Images. I have to download them when I first launch the application. I have also set boolean flag (with each IMAGE URL )in DB to check whether the image has been downloaded or not. If not fetch them else proceed to next URL. If image is fetched successfully, I have to save in storage and mark the corresponding flag as true so that I can directly search folder for the file. My understanding is:
1. Go through the DB file and find the items(rows) whose downloaded flag is false.
2. Gather all these URLs and send these to AsyncTask to download them.
My Sample DB structure:
| ItemName | LowResImageURL| HighResImageURL | LowResDownloaded | HighResDownloaded|
Query:
1. Once a image is downloaded, how can I get the reference of corresponding flag in DB so that I can set it as 'True' i.e.How to get/pass row reference to my ImageDownload method?
2. Best way to download approx 300 images from server.
Thanks
Sam

One thing that is coming to my mind is that I have to create a class to store the values from the DB then pass the object to async task, update the object accordingly after the image is downloaded and saved. After its done, update the DB from the updated class object.

Related

How to give the name to the child node in firebase

Whenever i will upload the data to the firebase it give random name to the child node. In the image "Upload" this name in given by me but what about inside name i want to change the name of inside the upload root how i can do that
The name inside the Upload is generated using push(), that you are using in your code, that is why you see it.
push() is a method that creates a random id to be able to seperate records in the database and also to be able to easily identify records in the Firebase Database.
push()
Create a reference to an auto-generated child location. The child key is generated client-side and incorporates an estimate of the server's time for sorting purposes. Locations generated on a single client will be sorted in the order that they are created, and will be sorted approximately in order across all clients.
more info here: https://firebase.google.com/docs/reference/android/com/google/firebase/database/DatabaseReference.html#push()

Changing Field Names In Firebase

Somehow in my firebase account 2 sets of data have changed the fieldname for 'DeviceID' to 'PeripheralID' and 'DeviceUUID'. Is there a way that I can search these and change them to be 'DeviceID'? I would prefer to do this by command line but will do whatever is easier.
Im thinking something along the line of firebase update:database ?
To answer the question with comments under question:
There is no tool for it. You'll have to download the data from database, edit JSON with some kind of text editor and upload it back to database.
This operation OVERRIDES information in database with information in JSON. In other words: uploading JSON changes database.
If you're using firebase console and data you want to change is not in whole database, you could open certain tree level and do those operation just there.

Toolbar display of an id specific variable from sqlite database very slow

Im using an sqlite database with provider and databasehelper. In a specific activity and some fragments (ordere by a FragmentPagerAdapter), I am trying to retrieve the name of a specific id to put it in the toolbar. I do this by creating a global variable with input from onLoadFinished in the activity and also in the fragments. This process is however very slow. The name is not immediately displayed. I have to refresh fragments (several times before the name is displayed. How can I make this more quick so that the name is immediately displayed?

Determine File Type of attachments stored in SQL Server as varbinary(MAX)

I need some help. We migrated an Access database to SQL Server. One column had attachment data the Attachment data type in MS Access. The MS Access application is being replaces by an ASP.NET web application.
This data now lives in a column of data type varbinary(MAX), there is no indication of the file name and or type (most attachments are Excel, Word and PDF docs).
In my ASP.Net application I am using a data reader that will allow users to retrieve the attachments by downloading them using a browser. (I have a new table for new attachments that contains the full file name and content type, and when present it works like a charm). Without the file types, all attachments come across as xml/garbles data files like shown in this image below (can't yet post images, been a long time reader, first contribution. Here is the text in which I had planned to highlight some key values:
ÿÿÿÿWorksheetExcel.Sheet.12****Access.OLE2Link¾ÐÏࡱá>þÿ þÿÿÿÿÿÿÿÿÿÿÿÿÿ]þÿÿÿþÿÿÿ !"#$%&'()*+,-./0123456789:;<=>?#ABCDEFGHIJKLMNOPQRSTUVWXYZ[\þÿÿÿþÿÿÿÿÿRoot EntryÿÿÿÿÿÿÿÿàÆ©÷òï…ÝŒkˆZ‚Å7Ï€Ole ÿÿÿÿÿÿÿÿÿÿÿÿCompObjÿÿÿÿeOlePres000ÿÿÿÿÿÿÿÿš­ þÿÿÿþÿÿÿþÿÿ‹ÀF CENTRA~1.XLSÿÿ­ÞHBCentral Dispatch Process Map.xlsxºÀF'C:\Users\MA~1\Desktop\CENTRA~1.XLSÿÿ­Þ]|C:\Users\ine\Desktop\Central Dispatch Process Map.xlsxÕLÀFƒ •Æh5)ÏBy>*Ϧc{>*ÏS5ŽŒ2S5&D%¯ CENTRA~1.XLSpï¾&D6®&D%¯*ƒœ2Central Dispatch Process Map.xlsxm-lkÑÊC:\Users\ine\Desktop\Central Dispatch Process Map.xlsx(
It appears that the content is there from which I should be able to extract the file name and types.
Here is my question, how do I migrate my attached files. I need to determine the content type and file names from the original data stored in varbinary(max), I then need to move the files from the current location into my new table with the attributes that describes the file name and file type.
Thanks

Image Comparison in ASP.NET

I'm developing a web application, Computerized Voting System using ASP.NET. i want to compare thumb impression from database. I'm using disconnected data access. is it possible to compare an input thumb impression with a thumb print already saved in SQL database? if yes then then how?
please describe some details of the application.
The images that are saved in the database, are they uploaded with the same application ? If so, you should add a new column where you will store the hash of the image.
You will have a table like this: |ID|ImageData|Hash|
This is how you can compute the hash:
string hash;
using(SHA1CryptoServiceProvider sha1 = new SHA1CryptoServiceProvider())
{
hash = Convert.ToBase64String(sha1.ComputeHash(byteArray));
}
Then, when you want to check if an uploaded image already exists in the database, you should compute the hash for it and send a query like:
string.Format("SELECT ID FROM Images WHERE Hash={0}", hash);
This will tell you if the exact same bytes are already in the database. If the image is similar, it will not work. It must be identical.
NOTE: you will have to convert your image into a byte array. This should not be a problem if you already do this when saving images in the database.
You might want to look in Computer Vision and Principal Component Analysis if you want to look for similarities between images.

Resources