0

i have a hard time figure out how to create a new table with my content provider, i have made one provider for this authority : com.mypackage.database/chats , inside it, it works well but i have several databases made with SqliteOpenHelper, with name for example "mydb.db" , in the same package . what i need is some thing like this :

     if(uriMatcher.match(Uri.parse("content://com.lifemate.lmmessenger.database/chats/mynewtable))== -1){

 System.out.println();
 Log.i("loader","Table Didnt Exists,Creating it...");
   String sqlCreate = "CREATE TABLE IF NOT EXISTS " + "'"+CurrentTarget+"'"
            + "  (_id           INTEGER PRIMARY KEY AUTOINCREMENT,"
            + "   username            TEXT,"
            + "   message           TEXT,"
            + "   isfile           TEXT,"
            + "   isright     INTEGER,"
            + "   time          CHAR,"
            + "   delivery INTEGER)";
    mDb.execSQL(sqlCreate);

    VCards.vCardsInstance.DownloadVCards(CurrentTarget);

 }

is there a way i can contact them with my ContentProvider, or is there any way i can Create a new Table Using the Provider? Thanks alot

Reza
  • 151
  • 1
  • 9

1 Answers1

0

A content provider can just access the database through an SQLiteOpenHelper object.

However, it might be easier to use a CursorLoader that does not need a content provider and accesses the database (helper) directly.

Community
  • 1
  • 1
CL.
  • 173,858
  • 17
  • 217
  • 259