2014-01-09 54 views
0

是否可以使用MySQL數據庫中的數據填充微調器而不使用PHP?我在這個問題上搜索了很多,我能找到的每個例子都包含一個PHP解決方案,最常見的是JSON。從數據庫只用Java填充微調器?

+0

的噴絲....在其上的環境? –

+0

你是什麼意思?作爲標籤的Android微調器建議。 – guitarzero

+1

是的,但我的意思是:數據在哪裏?你正在調用一個web服務?或者你已經在你的應用程序上有它? –

回答

0

您需要的是從Java應用程序打開數據庫連接並獲得所需的所有結果。

例如:

SQLiteDatabase db = LlistaRevisionsClientsActivity.getDB(context); 
Cursor cursorp = db.rawQuery("select * from table", null); 
try 
{ 
    if (cursorp.moveToFirst()) 
    { 
     if (productesRevisionsClientsCursor.moveToFirst()) 
     { 
      do{ 
       lst.add(cursorp.getString(cursorp 
        .getColumnIndex("nom"))); 
      } while (cursorp.moveToNext()); 
     } 
    } 
}finally 
{ 
    cursorp.close(); 
} 
spinner = (Spinner) findViewById(R.id.productes_spinner); 
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, 
     android.R.layout.simple_spinner_item, lst); 
// Specify the layout to use when the list of choices appears 
adapter.setDropDownViewResource(R.layout.spinner_productes); 
// Apply the adapter to the spinner 
spinner.setAdapter(adapter); 
+0

我會檢查一下。謝謝。 – guitarzero