English 中文(简体)
如何把我的数据库装到我的网站上,以用于我的和roid的仪器?
原标题:How to load my database to my website to be use in my android app?

Ok I am learning to use databases in android and have follow several tutorials that have teach me a lot, now I know how to include a prepopulated database and copy it to the app at the moment of installing and opening the app for the first time, showing its content in a list view. I have made the database using SQLite Database Browser, so my question is how can I instead of including this prepopulated database in my app assets folder have it uploaded to my website and getting it from there so I can do updates to the database there and not having to update the app every time the items in the database change? Can I keep using SQLite Database Browser to create my database? any comment is greatly appreciated, if you can share a tutorial that can help me getting this accomplish is very welcome too. in advance Thank you.

最佳回答

My solution came from YouTube and some tutorials from mimirsoft. 1st I created a database with the mysql wizard, 2nd in phpadmin I created a table with all the information I need in my app 3rd created a php file that querys the data from the database and creates a json string that I can call from my app. 4th in my app I create the call for the php file from ky website, set an adapter and holder for the info to display in my list view. That s it! It works, if want to achieve something similar ask and I can provide some code. Plus you can check the next link where you can find mimirsoft tutorial on this subject. Part 1 http://m.youtube.com/watch?v=P3CwlckiLTU And part 2 http://m.youtube.com/watch?v=HTIYt07NDRo

问题回答

Generate a sqlite dump file and import it in the database, replacing the necessary tables and data.

这是我在网络应用中所做的事,不是本土的复制,而是应该工作。

你可以采取几种办法。

一种办法是在你的网络服务器上安装LQite数据库。 然后,你可以进行某种检查,看看看它是否不同于你在你的装置上已经掌握的数据库。 例如,或许你们在服务器上都有一个文本文件,在服务器内有一个线,即数据库的版本。 在你的数据库中,你可能有一个表格,有一行,其中载有你目前的当地版本。 然后,你可以查询您的数据库,并与文本档案中的版本相比较。 如果当地数据库的版本少于文本档案中所列的版本,那么该版本就报废了当地版本,并采用了新的版本。

You can read the remote file by doing something like this:

URL myFileURL = null;
InputStream is = null;
String version = "";
try {
    myFileURL = new URL("http://www.mywebsite.com/dbversionfile.txt");
    is = myFileURL.openStream();
    BufferedReader br = new BufferedReader(new InputStreamReader(is, "UTF-8"));
    String line = "";
    while((line = br.readLine()) != null) {
        version = line;
    }
} catch (Exception e) { }

更好的解决办法是,在你提出申请的情况下,列入你的数据库。 只是一个包含所有适当表格的空洞数据库。 然后,你可以与你的网络服务器上的PHP/Java/etc网页联系,并获取目前贵国数据库中没有的任何数据。 如果你选择这一方法,你可能希望把每个数据都列入一个时间表。 这样,你就能够用最近最晚的时间,对您的仪器地方数据库进行查询。 如果这个时间序列从服务器数据库中退回不到一个,那么所有流量的回报都大于JSON格式。

如果你想使用这一方法,你可能会想研究安妮特·森松戈特。

I m sure there are other methods out there as well.





相关问题
what is wrong with this mysql code

$db_user="root"; $db_host="localhost"; $db_password="root"; $db_name = "fayer"; $conn = mysqli_connect($db_host,$db_user,$db_password,$db_name) or die ("couldn t connect to server"); // perform query ...

Users asking for denormalized database

I am in the early stages of developing a database-driven system and the largest part of the system revolves around an inheritance type of relationship. There is a parent entity with about 10 columns ...

Easiest way to deal with sample data in Java web apps?

I m writing a Java web app in my free time to learn more about development. I m using the Stripes framework and eventually intend to use hibernate and MySQL For the moment, whilst creating the pages ...

join across databases with nhibernate

I am trying to join two tables that reside in two different databases. Every time, I try to join I get the following error: An association from the table xxx refers to an unmapped class. If the ...

How can I know if such value exists in database? (ADO.NET)

For example, I have a table, and there is a column named Tags . I want to know if value programming exists in this column. How can I do this in ADO.NET? I did this: OleDbCommand cmd = new ...

Convert date to string upon saving a doctrine record

I m trying to migrate one of my PHP projects to Doctrine. I ve never used it before so there are a few things I don t understand. In my current code, I have a class similar to this: class ...

热门标签