如何在android studio应用程序上使用Web应用程序数据库 [英] How to use a web application database on android studio application

查看:263
本文介绍了如何在android studio应用程序上使用Web应用程序数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将我的网络应用数据库与我的Android应用程序链接



我尝试过:



I want to link my web app database with my android app

What I have tried:

SQLiteDatabase db = mDbHelper.getReadableDatabase();

// Define a projection that specifies which columns from the database
// you will actually use after this query.
String[] projection = {
    BaseColumns._ID,
    FeedEntry.COLUMN_NAME_TITLE,
    FeedEntry.COLUMN_NAME_SUBTITLE
    };

// Filter results WHERE "title" = 'My Title'
String selection = FeedEntry.COLUMN_NAME_TITLE + " = ?";
String[] selectionArgs = { "My Title" };

// How you want the results sorted in the resulting Cursor
String sortOrder =
    FeedEntry.COLUMN_NAME_SUBTITLE + " DESC";

Cursor cursor = db.query(
    FeedEntry.TABLE_NAME,   // The table to query
    projection,             // The array of columns to return (pass null to get all)
    selection,              // The columns for the WHERE clause
    selectionArgs,          // The values for the WHERE clause
    null,                   // don't group the rows
    null,                   // don't filter by row groups
    sortOrder               // The sort order
    );

推荐答案

你可能会写一个拉动的服务来自webapi的数据并放入本地SQLite DB。您可以安排该服务以特定间隔执行任务异步。此外,如果服务处于联机状态,您可以尝试同时更新两个数据库。您必须小心处理同步问题。
You probably can write a service that pulls data from webapi and puts into the local SQLite DB. You can schedule that service to do the task async at certain interval. In addition, you can try to update both db at the same time, if the service is online. You have to be careful with synchronizaiton issue.


这篇关于如何在android studio应用程序上使用Web应用程序数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆