[android-developers] how to avoid the creation of journal file in android.

2012-06-07 Thread Animesh kumar bhadra
Hi All,

I read through these two links:-

   1.
   
http://stackoverflow.com/questions/10046596/android-sqlite-journal-how-to-disable
   2.
   
http://www.android-app-market.com/sqlite-optimization-in-android-programming-sqlite-optimization-in-android-apps.html

and wanted to implement these and avoid the creation of journal file.

Here is my code:-

public void onOpen(SQLiteDatabase db) {
// TODO Auto-generated method stub
db.rawQuery(PRAGMA journal_mode=DELETE,null);
System.out.println(EventsData.onOpen());
super.onOpen(db);
}
which is according to option 1 listed above, i also tried OFF in place of
DELETE in the above query.

also as per the second option i did this:-
private void addEvent() {
SQLiteDatabase db = events.getWritableDatabase();
ContentValues values = new ContentValues();

db.beginTransaction();
try {
for(int i = 5; i  10; i++){
values.put(TIME, System.currentTimeMillis());
values.put(TITLE, MyString +i);
db.insertOrThrow(TABLE_NAME, null, values);
}
db.setTransactionSuccessful();
}finally{
db.endTransaction();
events.close();
}
}

but in both the case the journal file is getting created, can anyone please
let me know why is this happening and how can i avoid it?

Any help will be appreciated.

Regards,
Animesh K. Bhadra.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: how to avoid the creation of journal file in android.

2012-06-07 Thread animesh kumar bhadra
Hi,

I will take care for the journal rollback, but i want to know why the
file is getting created though i am making it off.

Also, i am running this on emulator.

Regards,
Animesh.

On Jun 7, 5:47 pm, Kostya Vasilyev kmans...@gmail.com wrote:
 http://www.sqlite.org/pragma.html#pragma_journal_mode



 The OFF journaling mode disables the rollback journal completely. No
 rollback journal is ever created and hence there is never a rollback
 journal to delete. *The OFF journaling mode disables the atomic commit and
 rollback capabilities of SQLite*. The ROLLBACK command no longer works; it
 behaves in an undefined way. Applications must avoid using the ROLLBACK
 command when the journal mode is OFF. *If the application crashes in the
 middle of a transaction when the OFF journaling mode is set, then the
 database file will very likely go corrupt.*
 

 Are you sure you want to do this?

 -- K

 2012/6/7 Animesh kumar bhadra animesh.bhadr...@gmail.com







  Hi All,

  I read through these two links:-

     1.
     http://stackoverflow.com/questions/10046596/android-sqlite-journal-ho...
     2.
     http://www.android-app-market.com/sqlite-optimization-in-android-prog...

  and wanted to implement these and avoid the creation of journal file.

  Here is my code:-

  public void onOpen(SQLiteDatabase db) {
          // TODO Auto-generated method stub
          db.rawQuery(PRAGMA journal_mode=DELETE,null);
          System.out.println(EventsData.onOpen());
          super.onOpen(db);
      }
  which is according to option 1 listed above, i also tried OFF in place of
  DELETE in the above query.

  also as per the second option i did this:-
  private void addEvent() {
          SQLiteDatabase db = events.getWritableDatabase();
          ContentValues values = new ContentValues();

          db.beginTransaction();
          try {
              for(int i = 5; i  10; i++){
                  values.put(TIME, System.currentTimeMillis());
                  values.put(TITLE, MyString +i);
                  db.insertOrThrow(TABLE_NAME, null, values);
              }
              db.setTransactionSuccessful();
          }finally{
              db.endTransaction();
              events.close();
          }
      }

  but in both the case the journal file is getting created, can anyone
  please let me know why is this happening and how can i avoid it?

  Any help will be appreciated.

  Regards,
  Animesh K. Bhadra.

  --
  You received this message because you are subscribed to the Google
  Groups Android Developers group.
  To post to this group, send email to android-developers@googlegroups.com
  To unsubscribe from this group, send email to
  android-developers+unsubscr...@googlegroups.com
  For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en