-3
04-24 12:15:21.671: E/AndroidRuntime(26419):java.lang.RuntimeException: Unable to start activity ComponentInfo{com.flocator/com.flocater.Friendfinderactivity}:android.database.sqlite.SQLiteException: near "null": syntax error(code 1): , while compiling: select * from null
這是我得到我每次我試圖compile..I時間誤差是一個學習的機器人,所以我不知道很多關於這個......所以誰能幫助我來解決這個問題.. 和我也得到錯誤Source not found
所以你能幫我解決這兩個問題。(1)近零語法錯誤
的代碼是在Friendfnderactivity.java
package com.flocater;
import com.flocator.R;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.telephony.TelephonyManager;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;
public class Friendfinderactivity extends Activity {
/** Called when the activity is first created. */
public static String deviceid = "deviceid";
public static String device_id = "device_id";
public static String user_id = "user_id";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
DBHelper dbhelper = new DBHelper(this);
SQLiteDatabase db = dbhelper.getWritableDatabase();
TelephonyManager tm = (TelephonyManager) this
.getSystemService(Context.TELEPHONY_SERVICE);
deviceid = tm.getDeviceId();
Cursor cursor = db.rawQuery("select * from "
+ Database.SUBSCRIBE_TABLE_NAME, null);
int rows = cursor.getCount();
if (rows > 0) {
cursor.moveToFirst();
user_id = cursor.getString(0);
device_id = cursor.getString(3);
}
db.close();
if (device_id.equals(deviceid)) {
setContentView(R.layout.subscriber);
} else
setContentView(R.layout.subscribe);
}
public void subscribeUser(View v) {
// get access to views
EditText editName = (EditText) this.findViewById(R.id.editName);
EditText editPhone = (EditText) this.findViewById(R.id.editPhone);
EditText editArea = (EditText) this.findViewById(R.id.editArea);
EditText editCity = (EditText) this.findViewById(R.id.editCity);
boolean done = Database.addUser(this, editName.getText().toString(),
editPhone.getText().toString(), deviceid, editArea.getText()
.toString(), editCity.getText().toString());
if(done) {
Toast.makeText(this, "Subscribed Successfully!", Toast.Length_Long).show();
Intent intent = new Intent(this,Friendfinderactivity.class);
startActivity(intent);
}
else
Toast.makeText(this, "Sorry! Could not subscribe!", Toast.LENGTH_LONG).show();
}
public void addFriends(View v) {
Intent intent = new Intent(this,AddFriends.class);
startActivity(intent);
}
public void viewFriends(View v) {
Intent intent = new Intent(this,SeeFriends.class);
startActivity(intent);
}
}
這是什麼數據庫?光標cursor = db.rawQuery(「select * from」 + Database.SUBSCRIBE_TABLE_NAME,null); – Amsheer
Database.SUBSCRIBE_TABLE_NAME的值是多少? – Pooja
* select * from null *,還有什麼可能是Database.SUBSCRIBE_TABLE_NAME的值? – Blackbelt