Android Open Source - sensor-supervisor Database Fragment






From Project

Back to project page sensor-supervisor.

License

The source code is released under:

GNU General Public License

If you think the Android project sensor-supervisor listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.thirdi.sensorsupervisor;
/*from   w  ww  .  j av  a  2  s  .  co m*/
import com.thirdi.sensorsupervisor.DBContract.DBEntry;

import android.app.Fragment;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.support.v4.widget.SimpleCursorAdapter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;

public class DatabaseFragment extends Fragment {

    SQLiteDatabase mDatabase;
    DBHelper mDbHelper;
  
    public DatabaseFragment() {
        // Required empty public constructor
      
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_database, container, false);
    }


    @Override
    public void onStart() {
        super.onStart();
        mDbHelper = new DBHelper(getActivity().getBaseContext());
        mDatabase = mDbHelper.getReadableDatabase();
        String[] projection = {
          DBContract.DBEntry._ID,
          //DBContract.DBEntry.COLUMN_NAME_SENSOR_ID,
          DBContract.DBEntry.COLUMN_NAME_SENSOR_NAME,
          DBContract.DBEntry.COLUMN_NAME_VALUE_X,
          DBContract.DBEntry.COLUMN_NAME_VALUE_Y,
          DBContract.DBEntry.COLUMN_NAME_VALUE_Z,
        };
        String sortOrder = DBContract.DBEntry._ID;
        Cursor cursor = mDatabase.query(
            DBContract.DBEntry.TABLE_NAME,
            projection,
            null,
            null,
            null,
            null,
            sortOrder);
        int[] views = {
            R.id._id,
            R.id.sensor_name,
            R.id.data_x,
            R.id.data_y,
            R.id.data_z,
        };
        ListView mListView = (ListView) getView().findViewById(R.id.listview);
        SimpleCursorAdapter mAdapter = new SimpleCursorAdapter(getActivity().getApplicationContext(),
            R.layout.db_list_item, cursor, projection, views, 0);
        mListView.setAdapter(mAdapter);
    }
}




Java Source Code List

com.thirdi.sensorsupervisor.AudioFragment.java
com.thirdi.sensorsupervisor.CameraFragment.java
com.thirdi.sensorsupervisor.CameraPreview.java
com.thirdi.sensorsupervisor.DBContract.java
com.thirdi.sensorsupervisor.DBHelper.java
com.thirdi.sensorsupervisor.DatabaseFragment.java
com.thirdi.sensorsupervisor.FileHelper.java
com.thirdi.sensorsupervisor.GPSFragment.java
com.thirdi.sensorsupervisor.MainActivity.java
com.thirdi.sensorsupervisor.MediaFragment.java
com.thirdi.sensorsupervisor.NavigationDrawerFragment.java
com.thirdi.sensorsupervisor.NetworkFragment.java
com.thirdi.sensorsupervisor.SensorFragment.java
com.thirdi.sensorsupervisor.SettingsFragment.java
com.thirdi.sensorsupervisor.WifiAdapter.java
com.thirdi.sensorsupervisor.maps.java