I am building a mileage tracking app for my personal use at work and am to populate a SQLite table with information about the trips I make. I have 2 spinners that allow me to select my starting and ending locations for a trip. I have a button that says, "Log Trip" and when I click on it, it should do an insert into the table with the information about my trip. Everything is working except for one of the spinners. No matter what I pick for my starting location in my app. The table populates the ending location in both starting and ending columns. For example, if I pick a trip going from locationA to locationB in my database the starting column will say locationB and the ending column will also say locationB.
Here is the code I have. Please help, thanks. ps. Very new to this so sorry if the code is crappy.
Code:
//When the Log Trip button is pressed, settings are saved to DB
final Button logTripBtn = (Button) findViewById(R.id.logTripBTN);
logTripBtn.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
DatePicker pickdate = (DatePicker) findViewById(R.id.datePicker1);
final int monthPicked = pickdate.getMonth();
final int dayPicked = pickdate.getDayOfMonth();
TimePicker pickTime = (TimePicker) findViewById(R.id.timePicker1);
final int hourPicked = pickTime.getCurrentHour();
final int minutePicked = pickTime.getCurrentMinute();
final EditText startingMileage = (EditText) findViewById(R.id.beginningMileageET);
final String startMiles = startingMileage.getText().toString();
final EditText endingMileage = (EditText) findViewById(R.id.endingMileageET);
final String endMiles = (String) endingMileage.getText().toString();
EditText tripComments = (EditText) findViewById(R.id.commentsET);
final String comment = (String) tripComments.getText().toString();
//Gets and stores the selected spinner values
Spinner originLocationSpinner = (Spinner) findViewById(R.id.originSpinner);
Spinner destinationLocationSpinner = (Spinner) findViewById(R.id.destinationSpinner);
final String originSpinnerSelected;
final String destinationSpinnerSelected;
Cursor c1 = (Cursor)(originLocationSpinner.getSelectedItem());
Cursor c2 = (Cursor)(destinationLocationSpinner.getSelectedItem());
if ((c1 != null) && (c2 != null)) {
originSpinnerSelected = c1.getString(c1.getColumnIndex(mDbHelper.LOCATIONS_COLUMN1));
destinationSpinnerSelected = c2.getString(c2.getColumnIndex(mDbHelper.LOCATIONS_COLUMN1));
//Calls method in mileagDbAdapter.java that inserts the trip information into the database
mDbHelper.logTripInfo(originSpinnerSelected, destinationSpinnerSelected, startMiles, endMiles, monthPicked, dayPicked, hourPicked, minutePicked, comment);
}}
});
Related
Hi, i'm currently exploring the gps on my device with the java api provided with the Android SDK.
I stumbled upon something that I can't make sense of: I collect the satellites my GPS sees and query those satellites it they are involved in the current fix and if they contain almanac and ephemeris data.
Now, somehow I never get a confirmation that the GPS i query contains eph or alm data? Turning on or off the aGPS don't really like to influence this. (FYI i'm running this on a Galaxy S)
I wonder, can someone try the attached program on his or her Android device and report back to me if the abbreviations "eph" and/or "alm" appear after the listed satellites.
Thanks in advance!
by request: code of the app (be warned this was my very first android app ):
Code:
package com.appelflap.android.location_app;
import java.util.Iterator;
import android.app.Activity;
import android.content.Context;
import android.location.GpsSatellite;
import android.location.Location;
import android.location.GpsStatus;
import android.location.LocationListener;
import android.location.GpsStatus.Listener;
import android.location.LocationManager;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;
public class LocationActivity extends Activity implements LocationListener, GpsStatus.Listener {
private static final String TAG = "com.appelflap.android.location_app";
private LocationManager locationManager;
private static final String PROVIDER = "gps";
private TextView output;
private TextView accuracy;
private TextView gpsstatus;
private TextView gpsfix;
private TextView gps_output;
private TextView line;
private TextView maxSatellites;
private TextView maxLocked;
private TextView minSignalNoiseRatio;
private Integer iGpsStatus;
private Integer maxSats;
private Integer maxFix;
private Integer minSnr;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
maxSats = 0;
maxFix = 0; // maximal number of sats constituting a fix. The claim for the SGS is that this is always =< 8
minSnr = 100; // minimal Snr of a sat contained in a fix. The claim for the SGS is that this is always > 20 (Lets start set with an unreal high value)
iGpsStatus = -1 ;
output = (TextView) findViewById(R.id.output);
accuracy = (TextView) findViewById(R.id.accuracy);
line = (TextView) findViewById(R.id.line);
maxSatellites = (TextView) findViewById(R.id.maxSatellites);
maxLocked = (TextView) findViewById(R.id.maxLocked);
minSignalNoiseRatio = (TextView) findViewById(R.id.minSignalNoiseRatio);
gpsfix = (TextView) findViewById(R.id.gpsfix);
gpsstatus = (TextView) findViewById(R.id.gpsstatus);
gps_output = (TextView) findViewById(R.id.gps_output);
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
locationManager.requestLocationUpdates(PROVIDER, 0, 0, this);
locationManager.addGpsStatusListener(this);
}
private void registerLocationListeners() {
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
locationManager.requestLocationUpdates(PROVIDER, 0, 0, this);
locationManager.addGpsStatusListener(this);
}
public void onLocationChanged(Location location) {
String result = String.format(
"Coordinates: latitude: %f, longitude: %f", location
.getLatitude(), location.getLongitude());
Log.d(TAG, "location update received: " + result);
output.setText(result);
accuracy.setText("Accuracy: " + location.getAccuracy());
}
public void onProviderDisabled(String provider) {
Log.d(TAG, "the following provider was disabled: " + provider);
}
public void onProviderEnabled(String provider) {
Log.d(TAG, "the following provider was enabled: " + provider);
}
public void onStatusChanged(String provider, int status, Bundle extras) {
Log.d(TAG, String.format(
"Provider status has changed. provider: %s, status: %d",
provider, status));
}
public void onGpsStatusChanged(int event)
{
Log.v("TEST","LocationActivity - onGpsStatusChange: onGpsStatusChanged: " + Integer.toString(event)) ;
int iSats;
int fix;
int snr;
switch( event )
{
case GpsStatus.GPS_EVENT_STARTED:
iGpsStatus = event ;
break ;
case GpsStatus.GPS_EVENT_SATELLITE_STATUS:
GpsStatus xGpsStatus = locationManager.getGpsStatus(null) ;
Iterable<GpsSatellite> iSatellites = xGpsStatus.getSatellites() ;
Iterator<GpsSatellite> it = iSatellites.iterator() ;
iSats = 0 ; // Satellite Count
fix = 0 ; // Count satellites used in fix
StringBuilder s = new StringBuilder();
while ( it.hasNext() )
{
iSats++ ;
GpsSatellite oSat = (GpsSatellite) it.next() ;
s.append(oSat.getPrn());
s.append(": ");
snr = (int) oSat.getSnr();
s.append(snr);
s.append(" Snr");
if ( oSat.usedInFix() ) {
s.append(" (*) ");
fix++;
// if snr of this locked sat < minSnr then update minSnr
if (snr < minSnr) {
minSnr = snr;
minSignalNoiseRatio.setText("Min Snr: " + minSnr);
}
// Just testing for ephemeris and almanac data. On the Galaxy S the following GpsSatelite methods
// always return "false". To do: formatting the output..
}
if ( oSat.hasEphemeris() ) {
s.append(" Eph ");
}
if ( oSat.hasAlmanac() ) {
s.append(" Alm ");
}
s.append("\n");
Log.v("TEST","LocationActivity - onGpsStatusChange: Satellites: " + oSat.getSnr() ) ;
}
gpsstatus.setText("Satellites: " + iSats);
gpsfix.setText("Locked: " + fix);
Log.v("TEST","LocationActivity - onGpsStatusChange: Satellites: " + iSats ) ;
if ( s.length() > 0) {
gps_output.setText(s.toString());
}
else { gps_output.setText("Waiting..."); }
if ( iSats > maxSats ) {
maxSats = iSats;
maxSatellites.setText("Max Sats: " + maxSats);
}
if ( fix > maxFix ) {
maxFix = fix;
maxLocked.setText("Max Locked: " + maxFix);
}
break ;
case GpsStatus.GPS_EVENT_FIRST_FIX:
iGpsStatus = event ;
break ;
case GpsStatus.GPS_EVENT_STOPPED:
gpsstatus.setText("Stopped...") ;
iGpsStatus = event ;
break ;
}
}
protected void onPause() {
// Make sure that when the activity goes to
// background, the device stops getting locations
// to save battery life.
locationManager.removeUpdates(this);
super.onPause();
}
protected void onResume() {
// Make sure that when the activity has been
// suspended to background,
// the device starts getting locations again
registerLocationListeners();
super.onResume();
}
}
// Framework for the code based on http://www.hascode.com/2010/05/sensor-fun-location-based-services-and-gps-for-android/
bumperdibump
LocationApp could not be installed on this phone.
System Requirements? I'm running Android 1.6
t-bon3 said:
LocationApp could not be installed on this phone.
System Requirements? I'm running Android 1.6
Click to expand...
Click to collapse
I attached another version for all Android levels. I checked with the api docs and it should run.
Thank you very much for testing!
I get a list of saetllites with a number, 'Snr' then a (*) for the sats that have a lock, but nothing else, no 'Eph' or 'Alm'.
This is on Android 1.6 on an i-mobile i858 device.
Do you have sample code for a simple app that reads data from the GPS. GPS software from the market seems buggy on my device and I would like to investigate by writing my own basic GPS app.
Thanks.
t-bon3 said:
I get a list of saetllites with a number, 'Snr' then a (*) for the sats that have a lock, but nothing else, no 'Eph' or 'Alm'.
This is on Android 1.6 on an i-mobile i858 device.
Do you have sample code for a simple app that reads data from the GPS. GPS software from the market seems buggy on my device and I would like to investigate by writing my own basic GPS app.
Thanks.
Click to expand...
Click to collapse
No problem, I will clean up the code somewhat and will put it up in the first post.
BTW did you activated aGPS while testing the app?
On my device under "My Location" in settings there are only these options:
Use wireless networks
Enable GPS satellites
Share with Google
I had all 3 set to active while testing the app.
t-bon3 said:
On my device under "My Location" in settings there are only these options:
Use wireless networks
Enable GPS satellites
Share with Google
I had all 3 set to active while testing the app.
Click to expand...
Click to collapse
The aGPS function has to be activated in an app delivered with your device. Don't know if it is activated by default. (assuming your GPS chip supports aGPS of course)
Anyway, I put the code up in the first post. (EDIT: included the resource files and the manifest file in a attached zip file)
here is the original htc apk. I was able to uncompress it, extract the class file and open it in a jave environment, what i need help is i found where it shows the following
public class FlashRestriction
{
private static final byte BATTERY_CAPACITY_FLAG = 1;
private static int BATTERY_CAPACITY_LIMIT = 0;
private static final String BATTERY_CAPACITY_LIMIT_PATH = "/sys/camera_led_status/low_cap_limit";
private static final String BATTERY_CAPACITY_PATH = "/sys/class/power_supply/battery/capacity";
private static final byte BATTERY_TEMPERATURE_FLAG = 2;
private static int BATTERY_TEMPERATURE_LIMIT = 0;
private static final String BATTERY_TEMPERATURE_LIMIT_PATH = "/sys/camera_led_status/low_temp_limit";
private static final String BATTERY_TEMPERATURE_PATH = "/sys/class/power_supply/battery/batt_temp";
private static final byte HOTSPOT_STATUS_FLAG = 16;
private static final String HOTSPOT_STATUS_PATH = "/sys/camera_led_status/led_hotspot_status";
private static final byte NO_LIMIT_FLAG = 0;
private static final byte RIL_STATUS_FLAG = 8;
private static final String RIL_STATUS_PATH = "/sys/camera_led_status/led_ril_status";
private static final String TAG = "FlashRestriction";
private static final byte WIMAX_STATUS_FLAG = 4;
private static final String WIMAX_STATUS_PATH = "/sys/camera_led_status/led_wimax_status";
private byte mDisableFlash = 0;
private FileObserver mFileObserver_BatCap = null;
private FileObserver mFileObserver_BatTemp = null;
private FileObserver mFileObserver_HotSpot = null;
private FileObserver mFileObserver_RIL = null;
private FileObserver mFileObserver_Wimax = null;
private byte mIsLimitBatCap = 0;
private byte mIsLimitBatTemp = 0;
private byte mIsLimitHotSpot = 0;
private byte mIsLimitRIL = 0;
private byte mIsLimitWimax = 0;
private Handler mUIHandler = null;
static
{
BATTERY_CAPACITY_LIMIT = 15;
initBatteryLimit();
In the flashrestriction section but i cant get it to edit down to 5%
Is there anyone who can edit this apk so it will allow the camera flash to be used down to 5% and then resign it so we can install it over the current one or make a patch for the current installed version?
Thank you in advance.
Hi All,
I am a not experienced developer. All I want to do is make a small app to track information of football on TV. I want to do it through a small DB however I've been struggling a lot with an error I've been trying to discover in the last two weeks but I have not been able.
I have teh following code in the class I create the DB
public class DBAdapter {
public static final String KEY_ROWID = "_id";
public static final String KEY_GDATE = "gdate";
public static final String KEY_GTIME = "gtime";
public static final String KEY_GGAME = "ggame";
public static final String KEY_GCOMPETITION = "gcompetition";
public static final String KEY_GCHANNEL = "gchannel";
private static final String TAG = "DBAdapter";
private static final String DATABASE_NAME = "FonTV";
private static final String DATABASE_TABLE = "games";
private static final int DATABASE_VERSION = 2;
private static final String DATABASE_CREATE =
"create table games (_id integer primary key autoincrement, "
+ "gdate text not null, gtime text not null, ggame text not null" +
"gcompetition text not null, gchannel text not null);";
private final Context context;
private DatabaseHelper DBHelper;
private SQLiteDatabase db;
public DBAdapter(Context ctx)
{
this.context = ctx;
DBHelper = new DatabaseHelper(context);
}
private static class DatabaseHelper extends SQLiteOpenHelper
{
DatabaseHelper(Context context)
{
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
@Override
public void onCreate(SQLiteDatabase db)
{
try {
db.execSQL(DATABASE_CREATE);
} catch (SQLException e) {
e.printStackTrace();
}
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
{
Log.w(TAG, "Upgrading database from version " + oldVersion + " to "
+ newVersion + ", which will destroy all old data");
db.execSQL("DROP TABLE IF EXISTS contacts");
onCreate(db);
}
}
//---opens the database---
public DBAdapter open() throws SQLException
{
db = DBHelper.getWritableDatabase();
return this;
}
//---closes the database---
public void close()
{
DBHelper.close();
}
//---insert a contact into the database---
public long insertContact(String gdate, String gtime, String ggame, String gcompetition, String gchannel )
{
ContentValues initialValues = new ContentValues();
initialValues.put(KEY_GDATE, gdate);
initialValues.put(KEY_GTIME, gtime);
initialValues.put(KEY_GGAME, ggame);
initialValues.put(KEY_GCOMPETITION, gcompetition);
initialValues.put(KEY_GCHANNEL, gchannel);
return db.insert(DATABASE_TABLE, null, initialValues);
}
}
And the main class where I try to insert data has this:
public class ResultsDBActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
DBAdapter db = new DBAdapter(this);
db.open();
long id = db.insertContact("12/may", "08:00", "Leeds vs York", "JUME Cup", "ITV, BBC");
id = db.insertContact("13/may", "09:00", "London vs Bath", "JUME Cup", "ITV, BBC2");
db.close();
}
}
However when I try to run it, the debugger shows and error that says:
E/Database(330): android.database.sqlite.SQLiteException: no such table: games: , while compiling: INSERT INTO games(gchannel, ggame, gtime, gdate, gcompetition) VALUES(?, ?, ?, ?, ?);
I’ve trying to change parameters and many things but I haven’t found where the problem is. Can someone help me please?
I have 4 checboxes that i want to enter in the SQLite table. I want that the values of the checkboxes must only be saved if the checkbox's are ticked. This is the code that i have used. The checkboxes are getting saved to the database but all of them are getting saved, even the checbox's i didnt check. Please help me with the code
Code:
private void SaveContent() {
EditText IdInput = (EditText) findViewById(R.id.StationID);
EditText NameInput = (EditText) findViewById(R.id.StationName);
EditText EmailInput = (EditText) findViewById(R.id.Email);
EditText LocationInput = (EditText) findViewById(R.id.Location);
final CheckBox wifi = (CheckBox) findViewById(R.id.Wifi);
if (wifi.isChecked()) {
final String strWifi = wifi.getText().toString();
}
final CheckBox toilets = (CheckBox) findViewById(R.id.Toilets);
if (toilets.isChecked()) {
final String strToilets = wifi.getText().toString();
}
final CheckBox lifts = (CheckBox) findViewById(R.id.Lifts);
if (lifts.isChecked()) {
final String strLifts = lifts.getText().toString();
}
final CheckBox ramps = (CheckBox) findViewById(R.id.Ramps);
if (ramps.isChecked()) {
final String strRamps =ramps.getText().toString();
}
final String strWifi = wifi.getText().toString();
final String strToilets = toilets.getText().toString();
final String strRamps = ramps.getText().toString();
final String strLifts = lifts.getText().toString();
final String strStationID = IdInput.getText().toString();
final String strName = NameInput.getText().toString();
final String strEmail = EmailInput.getText().toString();
final String strLocation = LocationInput.getText().toString();
final String strStationType = StationType[position];
new AlertDialog.Builder(this)
.setTitle("Details entered")
.setMessage(
" Details entered:\n" + strStationID + "\n" + strName + "\n " + strStationType +
"\n" + strWifi + "\n" + strToilets + "\n" + strLifts + "\n" + strRamps + "\n" +
strLocation + "\n" + strEmail )
.setNeutralButton("Back",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
}
})
.setPositiveButton("Save",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
saveStation(strStationID, strName, strStationType, strWifi,strToilets, strLifts, strRamps, strLocation, strEmail);
}
}).show();
}
public void saveStation(String StationID, String StationName, String StationType, String Wifi, String Toilets,
String Lifts, String Ramps, String Location, String Email) {
try {
dbHelper.insertStation(StationID,StationName,StationType,Wifi,Toilets,Lifts,Ramps,Location,Email);
new AlertDialog.Builder(AddStation.this)
.setTitle("\nStation Saved Successfully\n")
.setNeutralButton("View",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int which) {
viewStatiton();
}
}).show();
} catch (SQLiteException sqle) {
android.util.Log.w(this.getClass().getName(),
" Error saving to database");
new AlertDialog.Builder(AddStation.this)
.setTitle("Couldn't save details")
.setNeutralButton("Next",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int which) {
// do nothing
}
}).show();
}
}
Code:
public class SQL extends SQLiteOpenHelper {
private static final String DATABASE_NAME = "FacilitiesReview";
static final String TABLE_NAME="Stations";
static final String COL_StationID="StationID";
static final String COL_StationNAME="StationName";
static final String COL_StationType="StationType";
static final String COL_Wifi="Wifi";
static final String COL_Toilets="Toilets";
static final String COL_Lifts="Lifts";
static final String COL_Ramps="Ramps";
static final String COL_Email="Email";
static final String COL_Location="Location";
private SQLiteDatabase database;
public SQL(Context context) {
super(context, DATABASE_NAME, null, 1);
database = getWritableDatabase();
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL("CREATE TABLE StationTable (StationID INTEGER PRIMARY KEY, StationName TEXT, " +
"StationType TEXT, Wifi TEXT, Toilets TEXT, Lifts TEXT, Ramps Text, Location TEXT, Email TEXT );");
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
android.util.Log.w(this.getClass().getName(),
DATABASE_NAME + " database upgrade to version " + newVersion + " old data lost");
db.execSQL("DROP TABLE IF EXISTS details");
onCreate(db);
}
public long insertStation(String StationID, String StationName, String StationType, String Wifi, String Toilets,
String Lifts, String Ramps, String Location, String Email) {
ContentValues rowValues = new ContentValues();
rowValues.put("StationID", StationID);
rowValues.put("StationName", StationName);
rowValues.put("StationType", StationType);
rowValues.put("Wifi", Wifi);
rowValues.put("Toilets", Toilets);
rowValues.put("Lifts", Lifts);
rowValues.put("Ramps", Ramps);
rowValues.put("Location", Location);
rowValues.put("Email", Email);
return database.insertOrThrow("Station", null, rowValues);
}
public long getNumberOfRecords() {
Cursor c = database.query("Station",null,null, null, null, null, null);
return c.getCount();
}
public Cursor getAllRecords() {
return database.query(TABLE_NAME, null, null, null, null, null,
COL_StationNAME);
}
public void deleteAllRecords() {
database.delete(TABLE_NAME, null, null);
}
}
Hi there,
I'm sorry but I can't find anything related to your question.
Please post that in the forum bellow for more answers from the experts:
> Android Development and Hacking > Android Q&A, Help & Troubleshooting
Also you can read about that here: IDEs, Libraries, & Programming Tools or App Development Forums
Good luck
Hi guys I am new to developing i need help with some codes. Hope you guys can help.
I am using Sqlite database i need to create a list view that display the word from database so hope you guys can help me. here is my code above. ty
//Code
public class Ortho extends ActionBarActivity {
private final String TAG = "Ortho";
DatabaseHelper dbhelper;
TextView word;
TextView mean;
AutoCompleteTextView actv;
Cursor cursor;
Button search;
int flag = 0;
ListView ls;
ArrayList<String> dataword;
@override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.ortho);
ls = (ListView) findViewById(R.id.mainlist);
ls.setVisibility(View.VISIBLE);
//need code here
dbhelper = new DatabaseHelper(this);
try {
dbhelper.createDataBase();
} catch (IOException e) {
Log.e(TAG, "can't read/write file ");
Toast.makeText(this, "error loading data", Toast.LENGTH_SHORT).show();
}
dbhelper.openDataBase();
word = (TextView) findViewById(R.id.word);
mean = (TextView) findViewById(R.id.meaning);
String[] from = {"english_word"};
int[] to = {R.id.text};
actv = (AutoCompleteTextView) findViewById(R.id.autoCompleteTextView);
SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, R.layout.singalline, null, from, to);
// This will provide the labels for the choices to be displayed in the AutoCompleteTextView
adapter.setCursorToStringConverter(new SimpleCursorAdapter.CursorToStringConverter() {
@override
public CharSequence convertToString(Cursor cursor) {
return cursor.getString(1);
}
});
adapter.setFilterQueryProvider(new FilterQueryProvider() {
@override
public Cursor runQuery(CharSequence constraint) {
cursor = null;
int count = constraint.length();
if (count >= 1) {
String constrains = constraint.toString();
cursor = dbhelper.queryr(constrains);
}
return cursor;
}
});
briza-jann23 said:
Hi guys I am new to developing i need help with some codes. Hope you guys can help.
I am using Sqlite database i need to create a list view that display the word from database so hope you guys can help me. here is my code above. ty
//Code
public class Ortho extends ActionBarActivity {
private final String TAG = "Ortho";
DatabaseHelper dbhelper;
TextView word;
TextView mean;
AutoCompleteTextView actv;
Cursor cursor;
Button search;
int flag = 0;
ListView ls;
ArrayList<String> dataword;
@override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.ortho);
ls = (ListView) findViewById(R.id.mainlist);
ls.setVisibility(View.VISIBLE);
//need code here
dbhelper = new DatabaseHelper(this);
try {
dbhelper.createDataBase();
} catch (IOException e) {
Log.e(TAG, "can't read/write file ");
Toast.makeText(this, "error loading data", Toast.LENGTH_SHORT).show();
}
dbhelper.openDataBase();
word = (TextView) findViewById(R.id.word);
mean = (TextView) findViewById(R.id.meaning);
String[] from = {"english_word"};
int[] to = {R.id.text};
actv = (AutoCompleteTextView) findViewById(R.id.autoCompleteTextView);
SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, R.layout.singalline, null, from, to);
// This will provide the labels for the choices to be displayed in the AutoCompleteTextView
adapter.setCursorToStringConverter(new SimpleCursorAdapter.CursorToStringConverter() {
@override
public CharSequence convertToString(Cursor cursor) {
return cursor.getString(1);
}
});
adapter.setFilterQueryProvider(new FilterQueryProvider() {
@override
public Cursor runQuery(CharSequence constraint) {
cursor = null;
int count = constraint.length();
if (count >= 1) {
String constrains = constraint.toString();
cursor = dbhelper.queryr(constrains);
}
return cursor;
}
});
Click to expand...
Click to collapse
Hi, thank you for using XDA assist.
There is a general forum for android here http://forum.xda-developers.com/android/help where you can get better help and support if you try to ask over there.
Good luck.
You can also ask here http://forum.xda-developers.com/coding/java-android