how to copy content from text file to database in android - android

I am currently working on an app, where users enter data in given editText fields for one row and add the data to database.
In case of multiple rows (e.g. 50) to add, I want to allow a user to supply data through text files in specific format with delimeters.
How do I select the file or get file path of that text file supplied by the user
and then use it in my app to add the data to database?

How can I read a text file from the SD card in Android?
How to read text file in Android?
Android read text raw resource file
check these answers for how to load file to your application. Regarding saving inputs to database you can use classic for loop and go through every row and save it to database

Related

How to add 2000+ lines of text in firebase real-time database but faster

I have 2000 quotes lines in the word file but I don't want to add all this manually because it will take a lot of time
here is how the database looks https://imgur.com/a/6E1Q9iq
is there any fast way to add all this data
here is the word file https://docs.google.com/document/d/1f3E1sTyA9Mt1_z7K_21IpyFYdKedDRQI/edit?usp=sharing&ouid=117337378540666660100&rtpof=true&sd=true if you want to have a look
right now I have 50+ quotes in it but I'm adding up to 2000 , just go through the word file and the database image so u can get a clear picture of how I want to store quotes in firebase

Storing and dynamically loading pdf files from server in node js

I am trying to create an app that displays a list of pdf files, and then load the pdf file in a new browser tab / android activity.
The idea is the user will click a button "Lectures" and then will be shown the list of lectures, clicking on any list item will load the specific pdf file.
I currently have a node js mysql back end, for user login and routes to other pages, which is followed up with both a handlebars and android front end.
I am struggling to understand how I can store pdf files so they can be called based on what the user clicks, I want to store the pdf files on a server rather than within my application and then call them when required.
I have seen a method using ejs view engine to render list of files in public folder, which then allows you to do this, but this entails storing pdfs within the application, alternatively I can host the files with my web hosting, still need to figure out how to load them based on user action.
Would appreciate any direction or solution!
Thanks in advance
Mohamed V
Without knowing how you have the DB set I will talk more along the lines of how you would do this and then modify as needed. In most cases you would probably want to use an object store to store the PDF files. This will allow for access on any application.
Your DB should contain a file name of the PDF file, as an example, lets say you table for 'files' is as such
id, filename, name, extension, courceID
Here you would have the filename maybe the extension type and a refrenceID
Next, in your response callback, you simply return the query for the files, for example let say you run a query like SELECT filename, name WHERE courceID = '12345'
You then return this to the view, if its ejs then you would just pass the object and do something like
<% for ( in in files ) {%>
<div><a href="url-to-object-store/<%-files[i].filename%>"><%-files[i].filename%>
<%}%>

Android Save EditText with Image

Right now I have a simple App that takes a picture and saves it to a folder. I'm trying to figure out a way to have a user answer questions about each picture (I would just be using EditTexts with that). Is there a way to connect those EditTexts with the image so that when I would open up the image on another page that i could click a button to view the information that was entered along with that image? I have an idea on how to code everything else, just not keeping the edittexts associated with the image. Any ideas would be greatly appreciated!
Thank you!
perhaps you could create a data file alongside the image that has the same name as the image file, but a different extension.
So if you are saving an image called img1.png you save another file alongside it called img1.txt which contains the data you collect from the EditText(s). How you format this data file will depend a bit on how much data you have to store, and what kind of structure the data needs to represent (if any)
Then when you load up a png to display it you'll need to also load up the txt file that shares the same name, and populate the data contained inside to some TextView or something near your ImageView.
Use a database. Make a table that associates images with the data you want. When you display the picture, read the info for that picture from the database and display that as well. Either store the images directly in the db or store them in a folder and use the filename as the primary key in the database table.
There's number of ways to accomplish this. You could use a hashmap where the String is the data they entered and int is the resourceID of the image. For persistent storage, I recommend an SQLite Database that stores the string in a column and the associated image in another.
A few options:
Save a file with the image.. Give it the same name but .txt or something. The file should probably be stored in the location returned by getFilesDir() . Alternatively you could use SharedPreferences.
Use an sqlite database
Save within the exif data of the image. Use the ExifInterface class with setAttribute/getAttribute to save the values.

how does RSS feed application keep items marked as read? android

I have an application that read an online xml file, now i want to implement such functionality that when the user has clicked on item (read the item), it will marked as read. My problem is how to keep the old items' read status when I request again the new content from that xml file? and when I delete the item from xml file, it then will delete such item on the phone too when the user reload the content.
There's two ways to implement it:
Keep local database (with corresponding Content Provider) which would store read statuses. E.g. You could have table with two fields 'Record Id in online xml' - 'Read status'. Using this way, 'read' status will bee stored locally and on another client user would see items not marked as read;
Send server acknowledgement that the item has been read, so next request it won't be presented in the xml file (or xml file would provide it as 'read'). This way depends on the server implementation, but more convenient because 'read' status might be propagated along many clients;

How to store data from XML file to SQLite database in android

I am developing an application -- When a user is successfully logged in, an XML file is fetched from a URL and the XML data is displayed in list view.
How do I store that data in SQLite database, such that an offline user can see the data stored in the database? I also want to create a refresh button, which displays an updated XML file and stores it in SQLite, when it is clicked.
1)Get that Xml
2)Parse the xml using sax or any other parser you prefer
For parsing tutorial
3)Use the parsed data as you need in your case put it into Database
For Database tutorial
4)Populate the list view For listview tutorial

Categories

Resources