My application does not use internet, though I am using php(json) to get certain data from a local mysql database and parse the JSONObject to Java and save it to sqlite in Android.
I am using this to dynamically populate my android menus from the mysql data(local database). I think this call for a better practice when it comes in getting updates in the database. I will be deleting the previous menu in my sqlite and fetch another data from mysql.
What I did since I want to update my sqlite database, I incremeted my database version if there are new updated. Also I put an indicator from my outside database so that my app can check if there are available updates.
Related
I'm building a songbook Android application that displays songs' lyrics that I provide and some data like how many likes it's got (user is able to like a song), etc. Something like Spotify but only with lyrics. I need to store over 700 songs and I don't know what method to choose. It would be great if I could display the data on a website in the future too.
I've heard of JSON and XML but never used it. I am familiar with SQL databases like MySQL or SQLite, but I need to store almost pure text (including new lines) with some meta data and I think a database will not be efficient. I thoght of storing txt files in SQLite BLOB format. Also it would be great if the user would not have to update the app after adding one song to the database. BUT I also need it to work when user is offline.
To this day I've only build desktop apps with no networking and no API use. I am ready to learn this so if you have an idea what should I choose, could you provide any tips how to start?
You could use SQLite to store those lyrics. According to SQLite documentation you can store string or blob with a length up to 2147483647. You could start by learning how to use room to implement the database in Android.
To add new songs, you would probably need to implement an API client, and I recommend you learn about Retrofit. Your app would check an API to determine if there is a new song and insert it into the SQLite local database.
I am fairly new to programming java and I just started working with SQLite databases. A school assignment is requiring me to create a stand alone GUI program that can store data. After some research, I will be using a SQLite manager downloaded from Firefox. After completing my project, will it still able to run stand alone? Or will the SQLite manager be required to input data. Thank you
Yes, if you include the respective SQLite libraries. In fact there is little need for the SQLite Manager although the resultant file could be copied and used.
In short the SQLite database is a file that you open (connect to) using the respective library functions/API. Noting that some functionality may depend upon the version of SQLite (which could well be lower on the SQLite Manager).
You could also manage without the SQLite Manager, creating the database and tables therein within the program. Generally you'd use a SQLite Manager to provide a pre-populated database (noting that if using a pre-populated database that identifiers (table and column names) should match (case doesn't matter)).
I have an application which pulls its data from a local XML file. However, the data changes overtime and I am looking for a way to update it without updating the whole application.
My main goal is to create an update method which would connect to Internet if such connection is possible and update the application so that the next time the application is launched without Internet access it would display the latest version of data.
Since Android application files are in read only state I need some sort of workaround. I am thinking of two possible approaches. First one is to download an extra file and work with it, and the second is to utilize a SQLite database.
So my questions are:
Is it possible to create application with updatable information?
If so what is the right approach to accomplish this?
I think you should use a "Fridge".
When first launch, take default data and store it in sd card or internal storage, and replace these data when an update occurs.
I am collecting data from a website and trying to save it to a database (or something similar that is very accessible) rather than having a heap of files on my desktop or in a folder.
There are many pages that I need to look at (1900 to be exact). I want to save time in getting this data, and decided to make a Java program to do this.
This is basically what I am trying to do.
Visit the webpage: www.TestWebsite.com/items/0
Save the (Name, Description, Image(png)) into one array/class to a Database.
Repeat until I get up to: www.TestWebsite.com/items/1899
I want to be able to access this data offline without having to need to go online to view it.
Any ideas on how I should start. I have made a basic webpage viewer, I am just missing the step in between saving the strings and images to a database.
I appreciate any help!
Actually just did this the other day. I used jsoup to scrap the webpages I needed and wrote to my local database. awesomely easy framework for webpage parsing.
It's fairly straightforward, but you'll need to learn a little SQL if you haven't already.
You'll also have to pick a database platform - I'd suggest SQLite for such a purpose, since the data is for personal use and it's lightweight and easy to set up.
Here's a tutorial on using JDBC (Java Database Connectivity) to talk with a SQLite database: http://en.wikibooks.org/wiki/Java_JDBC_using_SQLite. It goes from setup to inserting data, so once you've completed that it should be straightforward to modify your webpage viewing code to grab the data you need and shove it into the DB.
Good luck!
I want to save and load database on disk.
What I really want is to be able to do the typical application save as and open things with the database. Means when I want to save the database, I will click the save as button, and give a name to the database, and then save it. Later I want to be able to load back the database, by using open button to find the path to the database.
I'm using sqlite and java, and I heard that firefox bookmark manager using sqlite to store bookmarked data. And I don't know the correct term but roughly I want to be able to do like firefox bookmark manager to save and load the database.
Hope you guys can shed some light here.
You can use SQLite database files in two possible ways:
Like a database: Upon the first run of your application, you create the SQLite database file and create the schema (using CREATE TABLE SQL commands etc.). Then, whenever you want to change the saved data, you access your database file and execute single UPDATE, INSERT or DELETE statements to modify exactly those records that have changed. This makes operations such as Save as not quite straightforward, but it's comparably fast for large amounts of data where only small parts are modified.
Like a data file: Every time you save your data, you create a new database file (if there was one with the same name before, you delete it first). You then create the whole schema, and then you write all the information to the database file (using INSERT SQL statements). This allows you to handle things with the traditional Save/*Save as* commands.
For more detailed information, please ask more specifically; in particular, outline your problem if you need to know which approach serves you best.