listview行加载了sqlite数据以及来自其他字符串的数据

时间:2012-09-10 05:00:48

标签: android sqlite listview row sharedpreferences

我想找到正确的方法去做这件事。我是编程的新手,并花了无数个小时试图解决这个问题。我有一个listview,并且要使用来自我的sqlite数据库以及sharedpreferences数据库的信息填充每一行。基本上,我需要来自两个数据库的信息进入同一行。我可以设置从sqlite获取信息但我无法弄清楚如何将其他数据输入到行中。感谢您的任何反馈和见解!

 public class carsetup extends Activity {


    someData = getSharedPreferences(counter, 0);
String dataReturned2 = someData.getString("sharedString", "Number");


someData = getSharedPreferences(odometer, 0);
String dataReturned3 = someData.getString("codometer", "Number2");

    w = Integer.parseInt(dataReturned2);

  g = Integer.parseInt(dataReturned3);

  long m = realtime;
  int l = (int) m;

  int frealtime = l/10000;

  int ght = 8640/w;

  int k = frealtime/ght;

  int fred = g+k;




    ListContent = (ListView)findViewById(R.id.listView1);

    mySQLiteAdapter = new SQLiteAdapter(this);
    mySQLiteAdapter.openToWrite();



    cursor = mySQLiteAdapter.queueAll();
    String[] from = new String[]{SQLiteAdapter.KEY_I, SQLiteAdapter.KEY_CONTENT1, SQLiteAdapter.KEY_CONTENT2 , SQLiteAdapter.KEY_CONTENT3};
    int[] to = new int[]{R.id.id, R.id.text1, R.id.text3, R.id.button1};
    cursorAdapter =
        new SimpleCursorAdapter(this, R.layout.item, cursor, from, to);




    ListContent.setAdapter(cursorAdapter);

0 个答案:

没有答案