I am new to android programming and I am having a serious problem with sqlite database tables. My application is a communication app so what I want to do is creating a table when a user clicks on a list item. I didn't have a problem creating the main table where the user's friends details are stored. I am trying to to create a table when named after the user's friend that keeps the the messages shared between the two..... I have written a code that claims to be working when its not...
Here is the sample:
public class ActiveFriends extends Activity {
// this class has a list view with //user's already chatting members
//(list items populated by info from the main table)
}
the table has been created by the following class extending SQLiteOpenHelper
public class DatabaseHelper extends SQLiteOpenHelper {
public void onCreate(SQLiteDatabade db) {
String sql = "CREATE TABLE active-chats (id INTEGER PRIMARY KEY, username TEXT, user-email TEXT)";
db.execSQL(sql);
} }
Then I have this 'NewChat' class with a list view that I want to have a table created on item click. it picks the friend's email and remove all text including and after @ and create a table with that name to store in the database. Here is what I did:
public class NewChat extends Activity {
TextView email = (TextView) view.findViewById(R.id.email);
String username = "the processed email";
new NewChatHelper(this, username);
}
here is the Newchathelper class
public class NewChatHelper extends SQLitOpenHelper {
private String username;
public NewChatHelper(Context context, String username) {
this.username = username;}
public void onCreate(SQLiteDatabase db) {
String sql = "CREATE TABLE " + username + "(id integer primary key, message TEXT, date-send TEXT)";
db.execSQL(sql);
} }
..... the app runs fine it wont crash but it claims to have created the tables. when you run a query to show all tables you only see the android_metadata and active chats only.. ... How do I solve this.... thanks in advance
Aucun commentaire:
Enregistrer un commentaire