當前位置:首頁 » 安卓系統 » androidquery

androidquery

發布時間: 2023-04-03 18:28:28

『壹』 android里queryIntentActivities(resolveIntent, 0);返回的list的size為什麼是0

resolveIntent設置數凳的薯悉旅有問題陸悉。
Intent resolveIntent = new Intent(Intent.ACTION_MAIN, null);
resolveIntent.addCategory(Intent.CATEGORY_LAUNCHER);
PackageManager pm = context.getPackageManager();
List<ResolveInfo> apps = pm.queryIntentActivities(resolveIntent, 0);

『貳』 Android用query怎麼進行多條件查詢

sqliteDatabase 給我提供的方法很不實用,還是建議樓主自己寫sql語句,參數想怎麼傳都可以x0dx0a例如:Cursor c = db.rawQuery("select * from user where username=? and password = ?",x0dx0anew Stirng[]{"用戶名","密碼"});x0dx0ax0dx0a如果你非要調用SQLiteDatabase的query方法,那可以這樣x0dx0adb.query("表名", new String[]{"欄位1,欄位2"}, "條件1=? and 條件2=?", new String[]{"條件1的值,條件2的值"},null,null,null)

『叄』 android sqllite query()查詢

public Cursor query (String table, String[] columns, String selection, String[] selectionArgs,String groupBy, String having,String orderBy,String limit)參數如下:
table:表名。相當於select語句from關鍵字後面的部分。如果皮首是多表聯合查詢,可以用逗號將兩個表名分開。
columns:要查詢出來的列名。相當於select語句select關鍵字後面的部分。
selection:查詢條件子句,相當於select語句where關鍵字後面的部分,在條件子句允許使用佔位符「?」
selectionArgs:對應於selection語句中佔位符的值,值在數組中的位置與佔位符在語句中的位置必須一致燃鉛數,否則就會有異常。
groupBy:相當於select語句group by關鍵字後面的部分
having:相當於select語句having關鍵字後面的部分
orderBy:相當於select語句order by關鍵字後面的部分,如:personid desc, age asc;
limit:指定激拍偏移量和獲取的記錄數,相當於select語句limit關鍵字後面的部分。

『肆』 Android編程query的orderBy參數怎麼填

String orderBy. 你用的是逗握態 3,

return dbYx.query(YX_TABLE, new String[]{ KEY_YX_ID, KEY_YX_NAME, KEY_YX_NO, KEY_YX_VALUE}, null, null, null, null, null);


java">1.query(Stringtable,String[]columns,Stringselection,String[]selectionArgs,StringgroupBy,Stringhaving,StringorderBy,Stringlimit)

2.query(booleandistinct,Stringtable,String[]columns,Stringselection,String[]selectionArgs,StringgroupBy,Stringhaving,StringorderBy,Stringlimit,)

3.query(Stringtable,String[]columns,Stringselection,String[]selectionArgs,String皮李groupBy,Stringhaving,StringorderBy)

4.query(booleandistinct,Stringtable,String[]columns,山源Stringselection,String[]selectionArgs,StringgroupBy,Stringhaving,StringorderBy,Stringlimit)

『伍』 我把文件從保險箱移入存儲位置androidquery。現應怎麼查找

隨便下一個文件管理器都有搜索功能,搜索文件夾名稱就找到了

『陸』 android query 模糊查詢怎麼使用

Android中SQLite模糊查詢,可以直接使用Cursor 的query加入模糊查詢的條件即可。 使用query有如下方式: 1.使用這種query方法%號前不能加',以下為示例代碼: Cursor c_test = mDatabase.query(tab_name, new String[]{tab_field02}, tab_field02+" LIKE ? ", new String[] { "%" + str[0] + "%" }, null, null, null); 2.使用這種query方法%號前必須加',以下為示例代碼 : Cursor c_test=mDatabase.query(tab_name, new String[]{tab_field02},tab_field02+" like '%" + str[0] + "%'", null, null, null, null); 3.使用這種方式必須在%號前加' ,以下為示例代碼 : String current_sql_sel = "SELECT * FROM "+tab_name +" where "+tab_field02+" like '%"+str[0]+"%'"; Cursor c_test = mDatabase.rawQuery(current_sql_sel, null);

『柒』 android如何保存html文件,包括其中的圖片。

1、先示例圖片

2、操作代碼

package com.nekocode.xue.utils;

import java.io.File;

import java.io.FileOutputStream;

import java.util.ArrayList;

import java.util.regex.Matcher;

import java.util.regex.Pattern;

import android.content.ContentValues;

import android.content.Context;

import android.database.Cursor;

import android.database.sqlite.SQLiteDatabase;

import com.androidquery.AQuery;

import com.androidquery.callback.AjaxCallback;

import com.androidquery.callback.AjaxStatus;

import com.nekocode.xue.PublicData;

import com.nekocode.xue.PublicData.Subscribe;

public class HtmlStorageHelper {

private String URL = "http://eproject.sinaapp.com/fetchurl.php/getcontent/";

private PublicData pd;

private AQuery aq;

private SQLiteDatabase mDB;

private String mDownloadPath;


public HtmlStorageHelper(Context context) {

pd = PublicData.getInstance();

aq = new AQuery(context);

mDB = context.openOrCreateDatabase("data.db", Context.MODE_PRIVATE, null);

mDB.execSQL("create table if not exists download_html(_id INTEGER PRIMARY KEY AUTOINCREMENT, content_id TEXT NOT NULL, title TEXT NOT NULL)");


mDownloadPath = pd.mAppPath + "download/";

File dir_file = new File(pd.mAppPath + "download/");

if(!dir_file.exists())

dir_file.mkdir();

}


public void saveHtml(final String id, final String title) {

if(isHtmlSaved(id))

return;


aq.ajax(URL+id, String.class, new AjaxCallback<String>() {

@Override

public void callback(String url, String html, AjaxStatus status) {

File dir_file = new File(mDownloadPath + id);

if(!dir_file.exists())

dir_file.mkdir();


Pattern pattern = Pattern.compile("(?<=src=")[^"]+(?=")");

Matcher matcher = pattern.matcher(html);

StringBuffer sb = new StringBuffer();

while(matcher.find()){

downloadPic(id, matcher.group(0));

matcher.appendReplacement(sb, formatPath(matcher.group(0)));

}

matcher.appendTail(sb);

html = sb.toString();


writeHtml(id, title, html);

}

});

}


private void downloadPic(String id, String url) {

File pic_file = new File(mDownloadPath + id + "/" + formatPath(url));

aq.download(url, pic_file, new AjaxCallback<File>() {

@Override

public void callback(String url, final File file, AjaxStatus status) {

}

});

}


private void writeHtml(String id, String title, String html) {

File html_file = new File(mDownloadPath + id + "/index.html");

FileOutputStream fos = null;

try {

fos=new FileOutputStream(html_file);

fos.write(html.getBytes());

} catch (Exception e) {

e.printStackTrace();

}finally{

try {

fos.close();

} catch (Exception e2) {

e2.printStackTrace();

}

}


ContentValues values = new ContentValues();

values.put("content_id", id);

values.put("title", title);

mDB.insert("download_html", "_id", values);

}


public boolean isHtmlSaved(String id) {

File file = new File(mDownloadPath + id);

if(file.exists()) {

file = new File(mDownloadPath + id + "/index.html");

if(file.exists())

return true;

}

deleteHtml(id);

return false;

}


public String getTitle(String id) {

Cursor c = mDB.rawQuery("select * from download_html where content_id=?", new String[]{id});

if(c.getCount() == 0)

return null;


c.moveToFirst();

int index1 = c.getColumnIndex("title");


return c.getString(index1);

}


public ArrayList<Subscribe> getHtmlList() {

Cursor c = mDB.rawQuery("select * from download_html", null);

ArrayList<Subscribe> list = new ArrayList<Subscribe>();

if(c.getCount() != 0) {

c.moveToFirst();

int index1 = c.getColumnIndex("content_id");

int index2 = c.getColumnIndex("title");


while (!c.isAfterLast()) {

String id = c.getString(index1);

if(isHtmlSaved(id)) {

Subscribe sub = new Subscribe(

id,

c.getString(index2),

Subscribe.FILE_DOWNLOADED

);

list.add(sub);

}


c.moveToNext();

}

}


return list;

}


public void deleteHtml(String id) {

mDB.delete("download_html", "content_id=?", new String[]{id});

File dir_file = new File(mDownloadPath + id);

deleteFile(dir_file);

}

private void deleteFile(File file) {

if (file.exists()) { // 判斷文件是否存在

if (file.isFile()) { // 判斷是否是文件

file.delete(); // delete()方法 你應該知道 是刪除的意思;

} else if (file.isDirectory()) { // 否則如果它是一個目錄

File files[] = file.listFiles(); // 聲明目錄下所有的文件 files[];

for (int i = 0; i < files.length; i++) { // 遍歷目錄下所有的文件

this.deleteFile(files[i]); // 把每個文件 用這個方法進行迭代

}

}

file.delete();

} else {

//

}

}


private String formatPath(String path) {

if (path != null && path.length() > 0) {

path = path.replace("\", "_");

path = path.replace("/", "_");

path = path.replace(":", "_");

path = path.replace("*", "_");

path = path.replace("?", "_");

path = path.replace(""", "_");

path = path.replace("<", "_");

path = path.replace("|", "_");

path = path.replace(">", "_");

}

return path;

}

}

3、這段代碼簡單修改就可以用到自己的項目中了

『捌』 Android-Android用query怎麼進行多條件查詢

SQLiteDatabase db=dbHelper.getWritableDatabase();

db.delete("record","pulse=?and dia_pre=?"世閉,new String[]{record.get_pulse(),record.get_dia_pre()});//刪除所有pulse等於給定值並且dia_pre等於給定值的記茄桐錄

Cursor cursor=db.query("record",null,"sys_pre&gt;?and dia_pre&lt;?",new String[]{"120","85"},null,null,null);//多條件查詢記得String是數顫返坦組

『玖』 android資料庫查詢query的「不等於」條件怎麼寫

不等於皮扮是"<>"。

示隱握者灶薯例:

SELECT*FROMPersonsWHERECity<>'Beijing'查詢資料庫表Persons中,City欄位不等於Beijing的記錄。

『拾』 Arcgis for Android identify 和query查詢遇到的問題,求教

1、QueryTask:是一個進行空間和屬性查詢的功能類,它可以在某個地圖服務的某個子圖層內進行查詢,順便提一下的是,QueryTask進行查詢的地圖服務並不必須載入到Map中進行顯示。QueryTask的執行需要兩個先決條件:悶臘戚一個是需要查詢的圖層URL、一個是進行查詢的過濾條件。
下面是QueryTask的基本過程:

//新建一個QueryTask
QueryTask queryTask = new QueryTask("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/5");

// Query對象
Query query = new Query();

//傳入空間幾何范圍,可以不設置
//合法的geometry類型是Extent, Point, Multipoint, Polyline, Polygon
query.Geometry = geometry;

//是否返回查詢結果的空間幾何信息
query.ReturnGeometry = true;

//查詢結果返回的欄位,欄位必須在圖層中,欄位的大小寫可忽略
query.OutFields.AddRange(new string[] { "AREANAME", "POP2000" });
//quer.OutField.Add("*"局彎); //返回所有欄位

//查詢的where條件,可以是任何合法的SQL語句,可以不設置
query.Where = "POP2000 > 350000";

//非同步查詢,需要綁定queryTask的兩個事件,通過ExecuteCompleted得到查詢結果
queryTask.ExecuteCompleted += QueryTask_ExecuteCompleted;
queryTask.Failed += QueryTask_Failed;
queryTask.ExecuteAsync(query);

//同步查詢,不需要綁定事件,直接返回查詢結果
//FeatureSet featureSet = queryTask.Execute(query);

2、螞陵FindTask:允許對地圖中一個或多個圖層的要素進行基於屬性欄位值的查詢(search one or more layers in a map for features with attribute values that match or contain an input value)。FindTask不能進行「空間查詢」,因為FindTask可以對多個圖層進行查詢,所有它的url屬性需要指向所查詢的地圖服務的REST URL,而不像QueryTask需要指定某個圖層的URL。
下面是FindTask的基本過程:

//新建一個Find task
FindTask findTask = new FindTask("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/");

//非同步執行,綁定事件
findTask.ExecuteCompleted += FindTask_ExecuteCompleted;
findTask.Failed += FindTask_Failed;

//初始化FindParameters參數
FindParameters findParameters = new FindParameters();
findParameters.LayerIds.AddRange(new int[] { 3 }); //查找的圖層
findParameters.SearchFields.AddRange(new string[] { "NAME" }); //查找的欄位范圍
findParameters.ReturnGeometry = true;
findParameters.SearchText = FindTextBox.Text; //查找的「屬性值」

//設置查詢的LayerDefinitions
ESRI.ArcGIS.Client.LayerDefinition myDefinition = new ESRI.ArcGIS.Client.LayerDefinition();
myDefinition.LayerID = 3;
//設置LayerDefinition,屬性欄位「Name」屬於ID為0的圖層
//LayerDefinition的設置語句和Query中的Where語句一樣
myDefinition.Definition = "NAME = 'XXX'";

//創建一個ObservableCollection,add設置的LayerDefinition
System.Collections.ObjectModel.ObservableCollection<LayerDefinition> myObservableCollection =
new System.Collections.ObjectModel.ObservableCollection<LayerDefinition>();
myObservableCollection.Add(myDefinition);
findParameters.LayerDefinitions = myObservableCollection; //設置查詢的LayerDefinitions

//非同步執行
findTask.ExecuteAsync(findParameters);

3、IdentifyTask:是一個在地圖服務中識別要素(Feature)的功能類。通過IdentifyTask可以搜索地圖層中與輸入幾何形相交的要素(search the layers in a map for features that intersect an input geometry)。因為也是在多個圖層中查詢,所以Task的URL是動態圖層服務的地址。同樣,返回的要素都可以作為Graphic被添加到地圖的GraphicsLayer上。
基本過程如下:

//新建一個Identify task
IdentifyTask identifyTask = new IdentifyTask("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer");

//非同步執行,綁定事件
identifyTask.ExecuteCompleted += IdentifyTask_ExecuteCompleted;
identifyTask.Failed += IdentifyTask_Failed;

//初始化 Identify parameters
IdentifyParameters identifyParameters = new IdentifyParameters();
identifyParameters.LayerOption = LayerOption.all;

//傳遞地圖屬性給 identify parameters
identifyParameters.MapExtent = MyMap.Extent;
identifyParameters.Width = (int)MyMap.ActualWidth;
identifyParameters.Height = (int)MyMap.ActualHeight;

//輸入的幾何參數為一個點,args來自點擊事件
identifyParameters.Geometry = args.MapPoint; //Point Envelop Extent polyline polygon

//設置查詢的LayerDefinitions
ESRI.ArcGIS.Client.LayerDefinition myDefinition = new ESRI.ArcGIS.Client.LayerDefinition();
myDefinition.LayerID = 3;
//設置LayerDefinition,屬性欄位「Name」屬於ID為0的圖層
//LayerDefinition的設置語句和Query中的Where語句一樣
myDefinition.Definition = "NAME = 'XXX'";
//創建一個ObservableCollection,add設置的LayerDefinition
System.Collections.ObjectModel.ObservableCollection<LayerDefinition> myObservableCollection =
new System.Collections.ObjectModel.ObservableCollection<LayerDefinition>();
myObservableCollection.Add(myDefinition);
identifyParameters.LayerDefinitions = myObservableCollection; //設置查詢的LayerDefinitions

//非同步執行
identifyTask.ExecuteAsync(identifyParameters);

三種查詢的返回結果:
QueryTask:返回的是一個FeatureSet。Featureset.features[i]可以加入到GraphicsLayer上顯示,也可以通過Attributes屬性欄位得到屬性信息。
FindTask:返回的是一個FindResults數組, FindResults[i].feature可以加入到GraphicsLayer上顯示,也可以通過Attributes屬性欄位得到屬性信息。
IdentifyTask:返回的是一個IdentifyResults數組,IdentifyResults[i].feature可以加入到GraphicsLayer上顯示,也可以通過Attributes屬性欄位得到屬性信息。

熱點內容
vsgcc編譯器 發布:2025-07-05 00:48:03 瀏覽:902
長城h6第三代都有哪些配置 發布:2025-07-05 00:39:25 瀏覽:396
unix系統編程手冊 發布:2025-07-05 00:32:17 瀏覽:286
重慶壓縮機廠 發布:2025-07-05 00:14:53 瀏覽:757
php55兼容 發布:2025-07-05 00:14:52 瀏覽:545
公主出國訪問 發布:2025-07-05 00:13:26 瀏覽:570
伺服器IP作為登錄IP 發布:2025-07-05 00:10:56 瀏覽:979
防雷支架應配置什麼電纜 發布:2025-07-05 00:05:56 瀏覽:220
iosc語言函數 發布:2025-07-05 00:02:40 瀏覽:994
android打飛機 發布:2025-07-04 23:59:34 瀏覽:210