-1
ヘルプ!私はアンドロイドからデータベースにジオロケーションデータを転送しています。エラーメッセージを表示します。エラー:(45、46)エラー:シンボルメソッドgetWritableDatabase()を見つけることができません。助けて! enter image description hereSQLiteDatabase dbm = this.getWritableDatabase();再帰的
public class AndroidGPSTrackingActivity extends Activity {
Button btnShowLocation;
// GPSTracker class
GPSTracker gps;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
btnShowLocation.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
// create class object
gps = new GPSTracker(AndroidGPSTrackingActivity.this);
// check if GPS enabled
if(gps.canGetLocation()){
double latitude = gps.getLatitude();
double longitude = gps.getLongitude();
SQLiteDatabase dbm = this.getWritableDatabase();
ContentValues cv = new ContentValues();
cv.put("LAT_G",
gps.getLatitude());
cv.put("LANG", gps.getLongitude());
boolean result = dbm.insert("table name", cv);
Toast.makeText(getApplicationContext(), "Your Location is - \nLat: " + latitude + "\nLong: " + longitude, Toast.LENGTH_LONG).show();
}else{
// can't get location
// GPS or Network is not enabled
// Ask user to enable GPS/network in settings
gps.showSettingsAlert();
}
} }); } }
例を挙げてください。私は全く分かりません。 –