ここでは、この写真のようにセールスマンの仕事をシミュレートするシンプルな Android アプリを作成しようとしています。
Web サービスからアイテム、価格、およびアイテムの数量を文字列リストで受け取ります。問題を解決できるこのチュートリアル を見つけましたが、Web サービスから取得した文字列リストを渡すようにカスタマイズできませんでした。
これが私のWebサービスコードです:
public List<String> getProduct() {
try {
// Accessing driver from jar files
Class.forName("com.mysql.jdbc.Driver");
// here we create a variable for the connection called con
Connection con = DriverManager.getConnection ("jdbc:mysql://localhost:3306/db","root", "root");
// here we create our query
PreparedStatement statement= con.prepareStatement("select quantity,price,item FROM distribute");
//PreparedStatement statement2= con.prepareStatement("select Date FROM storage_other");
// Here we are going to create a variable to Execute the query
ResultSet rs=statement.executeQuery();
//int i=1;
while (rs.next()) {
ls6.add(rs.getString(1));
ls6.add(rs.getString(2));
ls6.add(rs.getString(3));
//i++;
}
//ls.toArray(ss);
} catch(Exception e) {
System.out.print(e);
}
//ls.toArray(ss);
return ls6;
}