[android-developers] Re: Database access error causes force close

2014-12-06 Thread Jim Graham
On Sat, Dec 06, 2014 at 01:13:37PM -0800, Ted P wrote:
 
 On another note, learning to use the debugger is pretty easy, and super 
 helpful especially in situations like this

That's ultimately what put me on the right track.  As it turns out, there
is some conflicting information.  The tables I try to read from don't
exist in the online version of the database (as indicated by an error
message in the debugger) and yet, a query on those tables returns all of
the expected data ... correctly.

The biggest thing I did was, upon seeing a new example, remove the
try/catch for the cursor and replace it with if (c != null).  That's
when it started working right, and those tables that don't exist gave
the cursor the exact data that's in them.  :-)

I don't understand the conflicting information, but hopefully that can
get sorted out sooner or later.

As to what code I'm using for the DataBaseHelper class, it's mostly
adapted from this example:
http://www.reigndesign.com/blog/using-your-own-sqlite-database-in-android-applications/

The SQL query itself (just one test one so far) is from many tutorials
with my own limited SQL experience providing the SQL portion.

Thanks,
   --jim

-- 
THE SCORE:  ME:  2  CANCER:  0
73 DE N5IAL (/4)  | 
spooky1...@gmail.com  | BOFH Excuse for the day:
 Running Mac OS X Lion  | Too many
ICBM / Hurricane: | .
   30.44406N 86.59909W| interrupts


-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[android-developers] Re: Database access error causes force close (Update)

2014-12-05 Thread Jim Graham
On Fri, Dec 05, 2014 at 02:59:20PM -0600, Jim Graham wrote:
 I'm trying to use an SQLite table with Android (and for almost the first
 time, period, but I familiarized myself with it using SQLite3 /
 tclsh8.4), and I've run into a bit of a problem where I can't seem to
 spot the error.

Update:  There may be a problem with the initial copying of the
database.  The copy in assets (according to ls -l is 150528,
but long size = new File(db.getPath()).length(); reports a size
of 12288.

Does Android silently do compression of the database?  Or was it only
partially copied, thus likely explaining the error?

Thanks,
   --jim

-- 
THE SCORE:  ME:  2  CANCER:  0
73 DE N5IAL (/4)MiSTie #49997   Running Mac OS X Lion 
spooky1...@gmail.com ICBM/Hurricane: 30.44406N 86.59909W

Do not look into waveguide with remaining eye!

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[android-developers] Re: Database Versions

2013-05-18 Thread Piren
http://stackoverflow.com/questions/8133597/android-upgrading-db-version-and-adding-new-table

On Saturday, May 18, 2013 6:06:26 AM UTC+3, Gerson Novais wrote:

 Hi,

 I need understand Database version on Android.

 Example:

 I have a application and have a database for this application right? 

 In two weeks i need change the database, then a version is change to 2 and 
 make the change in onUpgrade, right?

 I have 100 downloads for my application.
 50 have update the application but 50 not.

 in more two weeks i change the database to 3 and make the changes in 
 onUpgrade.

 My question is:
 I need make a FULL database structure in onCreate and need leave changes 
 make in 1 version to 2 version and the change in 2 version to 3 versions?

 This is make a BIG older changes and big file class. right?

 thanks

 Atenciosamente,
 Gerson Novais
  

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[android-developers] Re: Database and helpers

2012-09-30 Thread daulat bachhav
i think u using only one helper class it,s ok but you'r database size is 
high it,s not so difficult trace for attacer.


On Monday, 1 October 2012 06:42:46 UTC+5:30, Paula Castellanos wrote:

 Hi guys, 

 Do you know what is the best practice when I work a data base in Android, 
 I mean, I know when you have a table you have a helper, but can I have 
 only one helper, and it creates all tables. it's a good practice or not. 

 Thanks, and sorry if I have some mistakes 


-- 
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: Database example

2012-08-16 Thread RichardC
android-sdk\samples\android-16\NotePad

On Thursday, August 16, 2012 8:00:03 AM UTC+1, Sadhna Upadhyay wrote:



  Hi Everybody,
   please share with me database example 



-- 
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

Re: [android-developers] Re: Database example

2012-08-16 Thread Live Happy
may this well help you
http://www.vogella.com/articles/AndroidSQLite/article.html
On Thu, Aug 16, 2012 at 10:52 AM, RichardC
richard.crit...@googlemail.comwrote:

 android-sdk\samples\android-16\NotePad

 On Thursday, August 16, 2012 8:00:03 AM UTC+1, Sadhna Upadhyay wrote:



  Hi Everybody,
   please share with me database example

  --
 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

Re: [android-developers] Re: Database example

2012-08-16 Thread Angelo Luciani
You have to do 2 things:

*1. Create your class relate Database a Table you want create*

package com.angelo.sqllite;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class MioDatabaseHelper extends SQLiteOpenHelper {
private static final String DB_NAME = minchiature_db;
private static final int DB_VERSION = 1;
public MioDatabaseHelper(Context context) {
super(context, DB_NAME, null, DB_VERSION);
}

@Override
public void onCreate(SQLiteDatabase db) {
String sql = ;
sql += CREATE TABLE agenda (;
sql +=  _id INTEGER PRIMARY KEY,;
sql +=  nome TEXT NOT NULL,;
sql +=  cognome TEXT NOT NULL,;
sql +=  telefono TEXT NOT NULL;
sql += );
db.execSQL(sql);
}

@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
// Aggiornamento delle tabelle
}


}

*2.Use Your activity *

package com.angelo.sqllite;

import android.app.Activity;
import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.util.Log;

public class TestSqlLiteActivity extends Activity
{
private MioDatabaseHelper mioDatabaseHelper;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

 /***CREATE A
DATABASE**/

mioDatabaseHelper = new MioDatabaseHelper(this);
SQLiteDatabase db = mioDatabaseHelper.getWritableDatabase();
ContentValues values = new ContentValues();

values.put(nome, Mario);
values.put(cognome, Rossi);
values.put(telefono, 061299178);
long id = db.insert(agenda, null, values);

values.put(nome, Mario2);
values.put(cognome, Rossi2);
values.put(telefono, 0612991782);
id = db.insert(agenda, null, values);

values.put(nome, Mario3);
values.put(cognome, Rossi3);
values.put(telefono, 0612991783);
id = db.insert(agenda, null, values);


String query = SELECT _id FROM agenda WHERE cognome = ? ORDER BY
_id ASC;
String[] selectionArgs3 = { Rossi };
// I cursori sono gli oggetti di Android che permettono di navigare
all’interno di un result set, ossia
//nell’insieme dei risultati restituiti da una query.
Cursor cursor = null;
cursor = db.rawQuery(query, selectionArgs3);

int count = cursor.getCount();

System.out.println(il numero di dati contenuti nel database +
count);

while (cursor.moveToNext()) {

id = cursor.getLong(0);
System.out.println(Questo è l'ID +id);
String nome = cursor.getString(1);
System.out.println(Questo è l'ID +nome);
String cognome = cursor.getString(2);
System.out.println(Questo è il COGNOME +cognome);

}



 /***DROP
TABLE***/

db.execSQL(DROP TABLE agenda);

}

}




On Thu, Aug 16, 2012 at 9:55 AM, Live Happy livehap...@gmail.com wrote:

 may this well help you
 http://www.vogella.com/articles/AndroidSQLite/article.html
 On Thu, Aug 16, 2012 at 10:52 AM, RichardC richard.crit...@googlemail.com
  wrote:

 android-sdk\samples\android-16\NotePad

 On Thursday, August 16, 2012 8:00:03 AM UTC+1, Sadhna Upadhyay wrote:



  Hi Everybody,
   please share with me database example

  --
 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


-- 
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: Database getting blank in android

2012-08-08 Thread Nobu Games
Database corruption can also happen when you open the same database file 
multiple times simultaneously. When the database is broken SQLiteDatabase 
simply re-creates the database file by default. I think that is largely 
fixed in newer Android versions and you would get a DatabaseLockedException 
if you try to open it multiple times.

Make sure to:

   1. Only use a single SQLiteDatabase connection / SQliteOpenHelper per 
   database file
   2. Open / close that connection at appropriate times in your activity 
   life cycle.

About 2.:

If you create the connection in onCreate / onResume and close it in onStop 
or onDestroy for example it is very likely that you'll end up with two open 
SQLiteDatabase connection objects simultaneously because two activities are 
likely to intersect in that case. You could probably get around that by 
opening the connection object in onResume and closing it in onPause.

Alternatively you can keep your database connection object as a singleton 
in your application object for example. Keep a reference counter there too. 
Every time when your activity starts it can request the db connection and 
increment the reference counter by one. When your activity is done 
(onDestroy) it can decrement the counter. If the counter hits zero you can 
close the db connection.

On Wednesday, August 8, 2012 5:44:20 AM UTC-5, Abhi wrote:

 Hello,

 I am developing an app. It is working fine but if i left the app open for 
 few hours the database gets blank sometimes(1 out of 5). I tried hard to 
 track the issue but couldn't found any. I am using Sqlite database. Please 
 help me as soon as possible.

 Thanks
 Abhi


-- 
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: Database

2012-06-07 Thread imran ali
Hi Arun,
Follow this , 
http://www.helloandroid.com/tutorials/store-imagesfiles-database.

store byte array in db and at time of showing image,  convert byte 
array[from db] to bitmap.

Regards
Imran Ali

On Thursday, June 7, 2012 12:38:15 PM UTC+5:30, arun wrote:

 hai friends..

 how to store a image in database use web services..

 any one known plz help me.,,,

 thanks 
 Arunkumkar A





-- 
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: Database access.

2012-05-23 Thread Károly Holczhauser
Hello there!

 I had done the same, but a little different way.
 I found an xml library which was able to send messages to an
server( IP and Port). I had created another project (normal java) and
I had implemented there a server which was able to recive the android
clinet requests and communicate with MySql DB.
 After the development completed I had exported into a jar file the
server and just start it from a command line.

cheers,
Karoly

On máj. 21, 10:07, Laxmihari laksh.ne...@gmail.com wrote:
 Hello everybody ,

 I've just started Android application development only for my use. I
 succeed to develop small apps. Now, I'm trying to enhance my android
 development skills further and want to access central MySql database server
 from my android tablet / phone, like adding, deleting, modifying into the
 database using android coding.

 I'd appreciate your immediate answer on this topic.

-- 
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: Database access from another android phone.

2012-03-30 Thread Chris Stratton
Since devices on mobile networks generally can't be reached by incoming 
connections, you will probably have to have a server somewhere which all 
the mobile clients check in with so it can forward traffic between them 
(possible using C2DM to get their attention).

You will have to build functionality into the app running on each device so 
that it can accept requests for db operations from the server.

Do think about the privacy, battery life, and data plan limit/charges 
implications of what you are building.

On Friday, March 30, 2012 4:15:09 AM UTC-4, Kirupa wrote:

 I want to access database of an application(I know the structure of 
 database) from the another android phone.(every android phone has same 
 application same database).

-- 
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: Database management

2012-02-09 Thread A. Elk
You can't access files that don't belong to your application unless the 
file's creator makes them world-readable. This is a security feature. The 
same is true for databases.

I think there are content providers for MMS and SMS. Look in the Android 
Open Source repository. They're not documented, though, which means they're 
subject to change without notice. You'd have to figure out how to use them 
from the code, and then hope that you can get the proper permissions to 
access them.

You must never try to work directly with files unless the owner makes them 
world-readable *and* gives you permission to do so. To do otherwise is a 
security violation, and I suspect it's also a violation of your terms of 
service with Google. Worst of all, you would be showing that you are a Bad 
Person. In Android, stuff is made inaccessible for a reason. No matter how 
much you'd like to look at it, you're better off doing something else.

I'd like to know *why* you need to do this. It's always better to ask How 
do I manage SMS messages, even if they're not mine rather than asking How 
to I get around a fundamental feature of the platform that isn't meant to 
be gotten around?

Of course, you may be doing this for your own device, with no intention of 
distributing the app. Even so, if you're using APIs that are not in the 
public reference, you have no guarantee of long-term stability.


-- 
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: Database Access from Android Application

2012-01-22 Thread Matt Clark
John,
The web script does not allow for open queries, it takes in the users
username, password, and device id, and authenticates them with the
server, before it then takes and executes a built in query on the
script, using more POST data. If i store each persons information into
different Tables, then the only thing that people can mess with is the
information for which they have a password to modify. This is what i
am currently using with PHP, and i see your point about embedding the
SQL information in the app.



On Jan 22, 7:15 am, Mark Murphy mmur...@commonsware.com wrote:
 On Sun, Jan 22, 2012 at 3:51 AM, Matt Clark mrclark32...@gmail.com wrote:
  Is there some kind of SQL library that i could
  just use insted of sending HTTP requests parsed by PHP files?

 That is not a good idea, for security reasons. That would mean that
 your database is open for the script kiddies of the world to attack,
 and that your database credentials are embedded in an APK for anyone
 to extract.

 --
 Mark Murphy (a Commons 
 Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy

 Warescription: Three Android Books, Plus Updates, One Low Price!

-- 
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: Database not created after insert, causing test to fail

2011-12-31 Thread barry
Hi James,

I think I have fixed the problem. The following may answer your
question:

In the onCreate() in my ContentProvider, I was leaving the database
open:

@Override
public boolean onCreate()
{
UKMPGDataProvider.init(getContext(), Constants.DATABASE_NAME);
return (UKMPGDataProvider.getWritableDatabase() == null) ? false :
true;
}
(In my defence, this was copied from a tutorial on the net.)

In my test, the addVehicle() would result in a call the
getWriteableDatabase() on SQLiteOpenHelper, which looks like this
(shortened for clarity):

public synchronized SQLiteDatabase getWritableDatabase() {
if (mDatabase != null  mDatabase.isOpen()  !
mDatabase.isReadOnly()) {
return mDatabase;  // The database is already open for
business
}

//lots more initialisation here, omitted
int version = db.getVersion();
if (version != mNewVersion) {
db.beginTransaction();
try {
if (version == 0) {
//DATABASE CREATED HERE
onCreate(db);
//END
} else {
onUpgrade(db, version, mNewVersion);
}
db.setVersion(mNewVersion);
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
}
//omitted code again
}
As I had left the database open, execution would not get passed the
first if statement and the onCreate(db) line would never be reached.

In my code, I would close the database after inserting a vehicle, so
next call to getWriteableDatabase() (getVehicles()) would get passed
the first if statement and execute the onCreate(db).

It doesn't really explain why the first insertion was successful
though. And it doesn't explain why the test passed in 'run' mode. I
added some logging to the onCreate() in my ContentProvider and
SQLiteOpenHelper and in run mode the ContentProvider onCreate() is
called twice.

I don't know if this made the difference or not... If anyone can shed
any light on what the difference is between run and debug when unit
testing, I'd be interested to learn more.

Thanks,
Barry

On Dec 31, 3:28 am, James Black planiturth...@gmail.com wrote:
 Where is the database table created?
 On Dec 30, 2011 6:54 PM, barry barry.drinkwa...@gmail.com wrote:







  I have an app which uses a sqlite database and a ContentProvider to
  serve up data. The eclipse project has a unit test which adds a record
  to a database, retrieves it and asserts against the retrieved data:

  public void testAddNewVehicle() { Vehicle vehicle1 = new
  Vehicle(xyz, my car, 111f); long result =
  VehicleProvider.addVehicle(getContext(), vehicle1);

  assertTrue(1 == result);

  ArrayListVehicle vehicles =
  VehicleProvider.getVehicles(getContext()) ;

  assertEquals(1, vehicles.size()); assertEquals(xyz,
  vehicles.get(0).getRegistrationNo()); assertEquals(my car,
  vehicles.get(0).getDescription()); assertEquals(111.0f,
  vehicles.get(0).getInitialMileage()); }

  My setup method deletes the database:

  @Override protected void setUp() throws Exception { super.setUp();
  deleteTestDatabase(); }

  The test passes when I choose 'run', but if I choose debug, it fails
  at theassertEquals(1, vehicles.size()); line. After stepping through
  the code I have noticed something strange: even though the data
  insertion succeeds and assertTrue(1 == result); passes, the database
  does not exist on the file system at this point. It is only created
  when VehicleProvider.getVehicles(getContext()); is called.

  Both addVehicle() and getVehicles() result in a call
  togetWritableDatabase(), so I don't see why the first call does not
  create the database on disk. The addVehicle() method will eventually
  call insert() (irrelevant code omitted):

  @Override public Uri insert(Uri uri, ContentValues values) { String
  table = table = Constants.VEHICLE_TABLE_NAME;

  long rowID = UKMPGDataProvider.getWritableDatabase().in sert(table,
  null, values);

  // ---if added successfully---if (rowID  0) { Uri insertedRowUri =
  insertedRowUri = ContentUris.withAppendedId(VEHICLE_CONTENT _URI,
  rowID);

  getContext().getContentResolver().notifyC hange(insertedRowUri, null);
  return insertedRowUri; } throw new SQLException(Failed to insert row
  into  + uri); }

  And the getVehicle() will eventually call query():

  @Override public Cursor query(Uri uri, String[] projection, String
  selection, String[] selectionArgs, String sortOrder)
  { SQLiteQueryBuilder sqlBuilder = new SQLiteQueryBuilder();

  sqlBuilder.setTables(uri.getPathSegments( ).get(0));

  if (uriMatcher.match(uri) == VEHICLE_ID) // ---if getting a particular
  vehicle

  sqlBuilder.appendWhere(BaseColumns._ID +  =  +
  uri.getPathSegments().get(1));

  if (sortOrder == null || sortOrder == ) { sortOrder =
  BaseColumns._ID; }

  Cursor c = sqlBuilder.query(UKMPGDataProvider.getWri tableDatabase(),
  projection, 

[android-developers] Re: Database not created after insert, causing test to fail

2011-12-30 Thread barry
My apologies for the formatting in the original message!

On Dec 30, 11:54 pm, barry barry.drinkwa...@gmail.com wrote:
 I have an app which uses a sqlite database and a ContentProvider to
 serve up data. The eclipse project has a unit test which adds a record
 to a database, retrieves it and asserts against the retrieved data:

 public void testAddNewVehicle() { Vehicle vehicle1 = new
 Vehicle(xyz, my car, 111f); long result =
 VehicleProvider.addVehicle(getContext(), vehicle1);

 assertTrue(1 == result);

 ArrayListVehicle vehicles =
 VehicleProvider.getVehicles(getContext()) ;

 assertEquals(1, vehicles.size()); assertEquals(xyz,
 vehicles.get(0).getRegistrationNo()); assertEquals(my car,
 vehicles.get(0).getDescription()); assertEquals(111.0f,
 vehicles.get(0).getInitialMileage()); }

 My setup method deletes the database:

 @Override protected void setUp() throws Exception { super.setUp();
 deleteTestDatabase(); }

 The test passes when I choose 'run', but if I choose debug, it fails
 at theassertEquals(1, vehicles.size()); line. After stepping through
 the code I have noticed something strange: even though the data
 insertion succeeds and assertTrue(1 == result); passes, the database
 does not exist on the file system at this point. It is only created
 when VehicleProvider.getVehicles(getContext()); is called.

 Both addVehicle() and getVehicles() result in a call
 togetWritableDatabase(), so I don't see why the first call does not
 create the database on disk. The addVehicle() method will eventually
 call insert() (irrelevant code omitted):

 @Override public Uri insert(Uri uri, ContentValues values) { String
 table = table = Constants.VEHICLE_TABLE_NAME;

 long rowID = UKMPGDataProvider.getWritableDatabase().in sert(table,
 null, values);

 // ---if added successfully---if (rowID  0) { Uri insertedRowUri =
 insertedRowUri = ContentUris.withAppendedId(VEHICLE_CONTENT _URI,
 rowID);

 getContext().getContentResolver().notifyC hange(insertedRowUri, null);
 return insertedRowUri; } throw new SQLException(Failed to insert row
 into  + uri); }

 And the getVehicle() will eventually call query():

 @Override public Cursor query(Uri uri, String[] projection, String
 selection, String[] selectionArgs, String sortOrder)
 { SQLiteQueryBuilder sqlBuilder = new SQLiteQueryBuilder();

 sqlBuilder.setTables(uri.getPathSegments( ).get(0));

 if (uriMatcher.match(uri) == VEHICLE_ID) // ---if getting a particular
 vehicle

 sqlBuilder.appendWhere(BaseColumns._ID +  =  +
 uri.getPathSegments().get(1));

 if (sortOrder == null || sortOrder == ) { sortOrder =
 BaseColumns._ID; }

 Cursor c = sqlBuilder.query(UKMPGDataProvider.getWri tableDatabase(),
 projection, selection, selectionArgs, null, null, sortOrder);

 // ---register to watch a content URI for changes---

 c.setNotificationUri(getContext().getCont entResolver(), uri);
 return
 c; }

 As I say, the test passes when not in debug mode.

-- 
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


Re: [android-developers] Re: database connectivity on real device

2011-12-04 Thread lbendlin
Now that you achieved that, do the following test:  Take out the SD card 
and run your app.

-- 
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

Re: [android-developers] Re: database connectivity on real device

2011-12-04 Thread Narendra Singh Rathore
Now that you achieved that, do the following test:  Take out the SD card
 and run your app.


I will definitely give that test later, and hopefully will achieve that.
anyways thanx for the challenging test. :)

-- 
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

Re: [android-developers] Re: database connectivity on real device

2011-12-03 Thread Narendra Singh Rathore
Yo, I achieved my goal by following steps..

1) Storing the database in assets folder.

2) Then from there, writing it to sdcard *programatically.*
**
3) Accessing it from SDCard.

Thnx all for directing me.

-- 
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: database connectivity on real device

2011-12-01 Thread gjs
Hi,

Create you database in code, when app is first run. Load data from
assets. If there is a lot of data load it from internet.

Regards

On Dec 2, 2:07 pm, Narendra Singh Rathore nsr.curi...@gmail.com
wrote:
 Hi again, my problem solved by storing my database in sdcard, but even now
 I have to push my database for the first time I m using it.

 Now, I want something likestoring my database in assets folder, so that
 it can directly be installed with the apk directly, without using push.

 Here is what I did.
 1) Copied the database in assets folder.

 Now, for accessing that database, I m doing---

 2) 
 db=*SQLiteDatabase.openDatabase*(file:android_assets/MY_DATABASEfile: 
 //android_assets/MY_DATABASE,
 null, SQLiteDatabase.CREATE_IF_NECESSARY);

 Am I doing something wrong here, let me know if I m wrong.

 I hope, u all got my problem..

 Narendra :(

-- 
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


Re: [android-developers] Re: database connectivity on real device

2011-12-01 Thread Narendra Singh Rathore
Create you database in code, when app is first run. Load data from
 assets. If there is a lot of data load it from internet.

 Regards


So, isn't it possible to use already made database from assets.
There should be some way to do this.

-- 
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

Re: [android-developers] Re: database connectivity on real device

2011-12-01 Thread Ajmer Singh
Hi

Your database file need to be less then 1 MB(as assets folder support file
less then 1 MB), You can split your database using hjsplit and then in
runtime combined the split files and put it in your package folder.

On Fri, Dec 2, 2011 at 11:35 AM, Narendra Singh Rathore 
nsr.curi...@gmail.com wrote:



 Create you database in code, when app is first run. Load data from
 assets. If there is a lot of data load it from internet.

 Regards


 So, isn't it possible to use already made database from assets.
 There should be some way to do this.

 --
 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




-- 
Thanks and Regards
Ajmer Singh

-- 
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

Re: [android-developers] Re: database connectivity on real device

2011-12-01 Thread Nikolay Elenkov
On Fri, Dec 2, 2011 at 3:05 PM, Narendra Singh Rathore
nsr.curi...@gmail.com wrote:


 Create you database in code, when app is first run. Load data from
 assets. If there is a lot of data load it from internet.

 Regards


 So, isn't it possible to use already made database from assets.
 There should be some way to do this.


Yes, it is. Create an empty database in the app's private folder, get
it's filename
and overwrite it with the database stored in assets. If the database
file is big
(more than 1MB), you'll have to split it or store it as a raw asset.

-- 
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


Re: [android-developers] Re: Database cursor as null

2011-10-09 Thread gyanu maharjan
hi , i have solved similar problem.i have a list generated from the phone
contact and on the top of populated list view i have added text field and
search button so the user can search from the populated list.You and my
fuction seems similar i.e list view Since i am using list view i used cursor
on the custom ListAdapter to populate the data  which i placed on
constructor declaration so the required data is available for render in
getView() of adapter.it worked fine for me and code is little complex for
 myself also when i look back at glance  on the list.setOnClickListener()
which i implement differently but Adapter portion is simple.I don't know how
you linking with helper class.

On Sun, Oct 9, 2011 at 8:45 AM, decode decode.develo...@gmail.com wrote:

 The data is quite huge, Like 10,000+ rows.
 cursor is declared in a helper class ...  a public class. I am closing
 the cursor in onDestroy of the class extending Application.

 There is a null check before launching the second activity. But, in
 second activity it is null. Doesnt happen always and not reproducible
 on our devices. Was reported by some users.





 On Oct 9, 8:27 am, lbendlin l...@bendlin.us wrote:
  is your cursor declared in the application or in the activity?
 
  As you already realised there is no real need to hold on to the cursor.
 All
  you need is the index of the table line for which you want to show the
 field
  data in the second activity.

 --
 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

[android-developers] Re: Database cursor as null

2011-10-08 Thread lbendlin
is your cursor declared in the application or in the activity? 

As you already realised there is no real need to hold on to the cursor. All 
you need is the index of the table line for which you want to show the field 
data in the second activity.

-- 
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: Database cursor as null

2011-10-08 Thread decode
The data is quite huge, Like 10,000+ rows.
cursor is declared in a helper class ...  a public class. I am closing
the cursor in onDestroy of the class extending Application.

There is a null check before launching the second activity. But, in
second activity it is null. Doesnt happen always and not reproducible
on our devices. Was reported by some users.





On Oct 9, 8:27 am, lbendlin l...@bendlin.us wrote:
 is your cursor declared in the application or in the activity?

 As you already realised there is no real need to hold on to the cursor. All
 you need is the index of the table line for which you want to show the field
 data in the second activity.

-- 
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


Re: [android-developers] Re: database query

2011-07-15 Thread Filip Havlicek
Actually if you navigate to the SQLite page on Android Developers (by simply
using the search bar and the SQL keyword), the Notepad tutorial is mentioned
there, so it is nowhere hidden, you just need to use the search and reading
skills.

2011/7/15 Indicator Veritatis mej1...@yahoo.com

 Obviously. But without being a little more specific, he will think you
 are just being rudely flippant. Especially since the title of the
 tutorial best for learning how to use the SQL database in Android does
 not even suggest that it covers SQL! I have in mind, of course, the
 tutorial he should start with (assuming he has completed the really
 basic ones),
 http://developer.android.com/resources/tutorials/notepad/notepad-ex1.html

 On Jul 14, 2:49 pm, Filip Havlicek havlicek.fi...@gmail.com wrote:
  I suggest you read the tutorials on the Android Developers site.
 
  2011/7/14 kirti waykole kirti.carr...@gmail.com hello all,
I am new in android . I want to use database for storing my
 application
   data.Plz tell me how to use database in android application
   Thanks in advance
   --
   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


-- 
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: database query

2011-07-14 Thread Indicator Veritatis
Obviously. But without being a little more specific, he will think you
are just being rudely flippant. Especially since the title of the
tutorial best for learning how to use the SQL database in Android does
not even suggest that it covers SQL! I have in mind, of course, the
tutorial he should start with (assuming he has completed the really
basic ones), 
http://developer.android.com/resources/tutorials/notepad/notepad-ex1.html

On Jul 14, 2:49 pm, Filip Havlicek havlicek.fi...@gmail.com wrote:
 I suggest you read the tutorials on the Android Developers site.

 2011/7/14 kirti waykole kirti.carr...@gmail.com hello all,
   I am new in android . I want to use database for storing my application
  data.Plz tell me how to use database in android application
  Thanks in advance
  --
  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


[android-developers] Re: database query

2011-07-14 Thread Chris
http://lmgtfy.com/?q=android+application+database

That should help you.

-- 
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

Re: [android-developers] Re: database query

2011-07-14 Thread kirti waykole
thank you so much for your valuable reply...it works

On Fri, Jul 15, 2011 at 8:09 AM, Chris crehb...@gmail.com wrote:

 http://lmgtfy.com/?q=android+application+database

 That should help you.

 --
 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

[android-developers] Re: Database error

2011-07-09 Thread Raghav Sood
UPDATE: I fixed it. I had a typo in the create statement. I accidentally
added a bracket after on of the floats.

On Sat, Jul 9, 2011 at 12:17 PM, Raghav Sood raghavs...@gmail.com wrote:

 Hi all,

 I am creating a database to store the list of earthquakes as an update to
 my existing app.

 I am receiving an error with the following caused by statement:
 Caused by: android.database.sqlite.SQLiteException: near ,: syntax error:
 create table earthquakes (_id integer primary key autoincrement, date
 INTEGER, details TEXT, latitude FLOAT, longitude FLOAT, magnitude FLOAT),
 link TEXT);
  My SQL statement is:

 private static class earthquakeDatabaseHelper extends SQLiteOpenHelper {

 private static final String DATABASE_CREATE =

   create table  + EARTHQUAKE_TABLE +  (

   + KEY_ID +  integer primary key autoincrement, 

   + KEY_DATE +  INTEGER, 

   + KEY_DETAILS +  TEXT, 

   + KEY_LOCATION_LAT +  FLOAT, 

   + KEY_LOCATION_LNG +  FLOAT, 

   + KEY_MAGNITUDE +  FLOAT), 

   + KEY_LINK +  TEXT);;


 As far as I can see the statement is fine. Please help.


 Thanks

 --
 Raghav Sood
 http://www.raghavsood.com/
 http://wiki.androidappcheck.com/
 http://www.telstop.tel/
 https://market.android.com/developer?pub=Raghav+Sood




-- 
Raghav Sood
http://www.raghavsood.com/
http://wiki.androidappcheck.com/
http://www.telstop.tel/
https://market.android.com/developer?pub=Raghav+Sood

-- 
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: Database path and writing

2011-07-06 Thread NikolaMKD
Sorry there is mistake.


Will openOrCreateDatabase open the database from /data/data/package/
file ?

On Jul 6, 3:55 am, NikolaMKD nikola.despoto...@gmail.com wrote:
 I have external databases stored in /data/data/files/

 Can I use openOrCreateDatabase( )? Will openOrCreateDatabase from that
 path?

 Using OpenDatabase(path,factory, mode) was not giving me ability to
 write into it? Why?

-- 
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


Re: [android-developers] Re: Database path and writing

2011-07-06 Thread Fred Niggle
Try it out and let us know.

If your new to databases there are lots of sqlite and sqlite3
tutorials related to android via google search :-)

On 06/07/2011, NikolaMKD nikola.despoto...@gmail.com wrote:
 Sorry there is mistake.


 Will openOrCreateDatabase open the database from /data/data/package/
 file ?

 On Jul 6, 3:55 am, NikolaMKD nikola.despoto...@gmail.com wrote:
 I have external databases stored in /data/data/files/

 Can I use openOrCreateDatabase( )? Will openOrCreateDatabase from that
 path?

 Using OpenDatabase(path,factory, mode) was not giving me ability to
 write into it? Why?

 --
 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


Re: [android-developers] Re: Database path and writing

2011-07-06 Thread Dayvid Victor
I don't know if it will work, but since you said you can't get the ability
to
write, it can be because of that.

On Wed, Jul 6, 2011 at 9:17 AM, NikolaMKD nikola.despoto...@gmail.comwrote:

 Sorry there is mistake.


 Will openOrCreateDatabase open the database from /data/data/package/
 file ?

 On Jul 6, 3:55 am, NikolaMKD nikola.despoto...@gmail.com wrote:
  I have external databases stored in /data/data/files/
 
  Can I use openOrCreateDatabase( )? Will openOrCreateDatabase from that
  path?
 
  Using OpenDatabase(path,factory, mode) was not giving me ability to
  write into it? Why?

 --
 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




-- 
Dayvid Victor R. de Oliveira
9º Periodo de Engenharia da Computação - UFPE
Monitor-Chefe de Lógica para Computação (EC)
Laboratório Itautec - CIn/UFPE

-- 
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: Database updates

2011-05-03 Thread Chambras
where did you change the version? in the manifest file or in the java class?

-- 
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: Database updates

2011-05-03 Thread harsh chandel
can you put the code

On May 3, 5:58 am, Albert Rosa rosalb...@gmail.com wrote:
 So this is my first time working with android and the sqlite db. I followed
 the instructions and was able to have a db connection where i was able to
 create and edit records. However i changed the schema of the db just to make
 it easier on me.

 Here is when i get slapped, i updated the version number, and modified the
 create statement to reflect the change. The onUpdate function is not being
 hit when i run the app again.

 Im not sure what I may be doing wrong. Any help suggestions are greatly
 welcomed and appreciated.

 Thanks for the help!

-- 
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


Re: [android-developers] Re: Database updates

2011-05-03 Thread Albert Rosa
Yes I changed the VERSION number on both the dbHelper file as well as the 
manifest

below is the code for the db helper:

public class RecipeDbHelper extends SQLiteOpenHelper {


private static final String DATABASE_NAME = test;
private static final String DATABASE_TABLE = recipe;
private static final int DATABASE_VERSION = 10;

private static final String DATABASE_CREATE = CREATE TABLE recipe ( 
_id INTEGER PRIMARY KEY, title text not null, ingredients text not null, 
instructions text not null, mealtime INTEGER not null, calories INTEGER not 
null);;

private static final String INITIAL_SETUP = 
INSERT INTO recipe (_id, title, instructions,ingredients, 
mealtime, calories) 
+ VALUES (1, 'Triple Veggie Scramble','1. Chop all veggies and 
set aside. Whisk eggs in bowl.\n2. Spray nonstick skillet with cooking spray 
and saute veggies until soft.\n3. Add whisked eggs, cheese and dash salt and 
pepper and cook until eggs are firm. \n4. Serve on toasted english muffin with 
sliced pear on the side.',
+'3 eggs (1 whole + 2 whites) \n1\\2 cup each chopped 
tomatoes, spinach and mushrooms\n1 oz reduced fat shredded cheddar cheese\n1 
Thomas Light Multigrain english muffin\nSmall pear, sliced.\nsalt/pepper to 
taste', 1, 124);
;

public RecipeDbHelper(Context context){
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}

public void clearReset(SQLiteDatabase db) {
Log.w(Upgrading, Upgrading database from version);
db.execSQL(DROP TABLE IF EXISTS + DATABASE_TABLE);
onCreate(db);
}

@Override
public void onCreate(SQLiteDatabase db){
db.execSQL(DATABASE_CREATE);
db.execSQL(INITIAL_SETUP);
}

@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int 
newVersion){
Log.w(Upgrading, Upgrading database from version  + 
oldVersion +  to 
+ newVersion + , which will destroy all old data);
db.execSQL(DROP TABLE IF EXISTS + DATABASE_TABLE);
onCreate(db);
}

thanks again I truly appreciate it.

Albert Rosa
rosalb...@gmail.com
alb...@albert-rosa.com
(m) 718-825-7838
(aim) albertrosa2000
(gchat) rosalbert
(gvoice) (646) 389-7672

On May 3, 2011, at 4:18 AM, harsh chandel wrote:

 can you put the code
 
 On May 3, 5:58 am, Albert Rosa rosalb...@gmail.com wrote:
 So this is my first time working with android and the sqlite db. I followed
 the instructions and was able to have a db connection where i was able to
 create and edit records. However i changed the schema of the db just to make
 it easier on me.
 
 Here is when i get slapped, i updated the version number, and modified the
 create statement to reflect the change. The onUpdate function is not being
 hit when i run the app again.
 
 Im not sure what I may be doing wrong. Any help suggestions are greatly
 welcomed and appreciated.
 
 Thanks for the help!
 
 -- 
 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


Re: [android-developers] Re: Database updates

2011-05-03 Thread Kostya Vasilyev

No idea what clearReset is, but

Call SQLiteDatabase.getVersion() somewhere, just to make sure your db's 
version is not already 10 (which would mean that there is nothing to 
upgrade).


-- Kostya

PS - Can I use butter instead of cooking spray? :)

03.05.2011 18:09, Albert Rosa пишет:

Yes I changed the VERSION number on both the dbHelper file as well as the 
manifest

below is the code for the db helper:

public class RecipeDbHelper extends SQLiteOpenHelper {


private static final String DATABASE_NAME = test;
private static final String DATABASE_TABLE = recipe;
private static final int DATABASE_VERSION = 10;

private static final String DATABASE_CREATE = CREATE TABLE recipe ( _id 
INTEGER PRIMARY KEY, title text not null, ingredients text not null, instructions text 
not null, mealtime INTEGER not null, calories INTEGER not null);;

private static final String INITIAL_SETUP =
INSERT INTO recipe (_id, title, instructions,ingredients, mealtime, 
calories) 
+ VALUES (1, 'Triple Veggie Scramble','1. Chop all veggies and set 
aside. Whisk eggs in bowl.\n2. Spray nonstick skillet with cooking spray and saute 
veggies until soft.\n3. Add whisked eggs, cheese and dash salt and pepper and cook until 
eggs are firm. \n4. Serve on toasted english muffin with sliced pear on the side.',
+'3 eggs (1 whole + 2 whites) \n1\\2 cup each chopped tomatoes, 
spinach and mushrooms\n1 oz reduced fat shredded cheddar cheese\n1 Thomas Light 
Multigrain english muffin\nSmall pear, sliced.\nsalt/pepper to taste', 1, 124);
;

public RecipeDbHelper(Context context){
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}

public void clearReset(SQLiteDatabase db) {
Log.w(Upgrading, Upgrading database from version);
db.execSQL(DROP TABLE IF EXISTS + DATABASE_TABLE);
onCreate(db);
}

@Override
public void onCreate(SQLiteDatabase db){
db.execSQL(DATABASE_CREATE);
db.execSQL(INITIAL_SETUP);
}

@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int 
newVersion){
Log.w(Upgrading, Upgrading database from version  + oldVersion + 
 to 
 + newVersion + , which will destroy all old data);
 db.execSQL(DROP TABLE IF EXISTS + DATABASE_TABLE);
 onCreate(db);
}

thanks again I truly appreciate it.

Albert Rosa
rosalb...@gmail.com
alb...@albert-rosa.com
(m) 718-825-7838
(aim) albertrosa2000
(gchat) rosalbert
(gvoice) (646) 389-7672



--
Kostya Vasilyev -- http://kmansoft.wordpress.com

--
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


Re: [android-developers] Re: Database updates

2011-05-03 Thread Albert Rosa
Ok so I've been able to place crazy amounts of logs every where and it does see 
to call onUpgrade to the next version and it is able to drop the table. 

I want validate the sql that its generating in order to get all the items. is 
there a way to get the raw sql that it's generating. I feel like i may be doing 
something wrong, rather I know I'm doing something wrong I just don't know... 

clearReset was a function I created in order to drop the table and reset it 
with preset data. it can be ignored.

I will try to find the db in the emulator by adb maybe I might surprise myself.


Albert Rosa
rosalb...@gmail.com
alb...@albert-rosa.com
(m) 718-825-7838
(aim) albertrosa2000
(gchat) rosalbert
(gvoice) (646) 389-7672

On May 3, 2011, at 11:55 AM, Kostya Vasilyev wrote:

 No idea what clearReset is, but
 
 Call SQLiteDatabase.getVersion() somewhere, just to make sure your db's 
 version is not already 10 (which would mean that there is nothing to upgrade).
 
 -- Kostya
 
 PS - Can I use butter instead of cooking spray? :)
 
 03.05.2011 18:09, Albert Rosa пишет:
 Yes I changed the VERSION number on both the dbHelper file as well as the 
 manifest
 
 below is the code for the db helper:
 
 public class RecipeDbHelper extends SQLiteOpenHelper {
 
 
  private static final String DATABASE_NAME = test;
  private static final String DATABASE_TABLE = recipe;
  private static final int DATABASE_VERSION = 10;
  
  private static final String DATABASE_CREATE = CREATE TABLE recipe ( 
 _id INTEGER PRIMARY KEY, title text not null, ingredients text not null, 
 instructions text not null, mealtime INTEGER not null, calories INTEGER not 
 null);;
  
  private static final String INITIAL_SETUP =
  INSERT INTO recipe (_id, title, instructions,ingredients, 
 mealtime, calories) 
  + VALUES (1, 'Triple Veggie Scramble','1. Chop all veggies and 
 set aside. Whisk eggs in bowl.\n2. Spray nonstick skillet with cooking spray 
 and saute veggies until soft.\n3. Add whisked eggs, cheese and dash salt and 
 pepper and cook until eggs are firm. \n4. Serve on toasted english muffin 
 with sliced pear on the side.',
  +'3 eggs (1 whole + 2 whites) \n1\\2 cup each chopped 
 tomatoes, spinach and mushrooms\n1 oz reduced fat shredded cheddar cheese\n1 
 Thomas Light Multigrain english muffin\nSmall pear, sliced.\nsalt/pepper to 
 taste', 1, 124);
  ;
  
  public RecipeDbHelper(Context context){
  super(context, DATABASE_NAME, null, DATABASE_VERSION);
  }
  
  public void clearReset(SQLiteDatabase db) {
  Log.w(Upgrading, Upgrading database from version);
  db.execSQL(DROP TABLE IF EXISTS + DATABASE_TABLE);
  onCreate(db);
  }
  
  @Override
  public void onCreate(SQLiteDatabase db){
  db.execSQL(DATABASE_CREATE);
  db.execSQL(INITIAL_SETUP);
  }
  
  @Override
  public void onUpgrade(SQLiteDatabase db, int oldVersion, int 
 newVersion){
  Log.w(Upgrading, Upgrading database from version  + 
 oldVersion +  to 
 + newVersion + , which will destroy all old data);
 db.execSQL(DROP TABLE IF EXISTS + DATABASE_TABLE);
 onCreate(db);
  }
 
 thanks again I truly appreciate it.
 
 Albert Rosa
 rosalb...@gmail.com
 alb...@albert-rosa.com
 (m) 718-825-7838
 (aim) albertrosa2000
 (gchat) rosalbert
 (gvoice) (646) 389-7672
 
 
 -- 
 Kostya Vasilyev -- http://kmansoft.wordpress.com
 
 -- 
 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


Re: [android-developers] Re: Database updates

2011-05-03 Thread Albert Rosa

OK so here's what I gathered,

after doing some investigation in the adb (AWESOME by the way) I noticed that 
there was nothing wrong with my inserts. But for some reason the second insert 
that is attached to INITIAL_SETUP is not run. wierd I know. but that clears up 
my confusion a bit. I am thinking that each db.execSQL can only use one 
statement at a time. I may be wrong but for now I think that's how it is. 

Luckily I found an article on copying db's over so I can pre-populate the db 
and then copy it over.

Thanks everyone for the advice and If i'm wrong in my assumptions please feel 
free to let me know. 


Albert Rosa
rosalb...@gmail.com
alb...@albert-rosa.com
(m) 718-825-7838
(aim) albertrosa2000
(gchat) rosalbert
(gvoice) (646) 389-7672

On May 3, 2011, at 11:55 AM, Kostya Vasilyev wrote:

 No idea what clearReset is, but
 
 Call SQLiteDatabase.getVersion() somewhere, just to make sure your db's 
 version is not already 10 (which would mean that there is nothing to upgrade).
 
 -- Kostya
 
 PS - Can I use butter instead of cooking spray? :)
 
 03.05.2011 18:09, Albert Rosa пишет:
 Yes I changed the VERSION number on both the dbHelper file as well as the 
 manifest
 
 below is the code for the db helper:
 
 public class RecipeDbHelper extends SQLiteOpenHelper {
 
 
  private static final String DATABASE_NAME = test;
  private static final String DATABASE_TABLE = recipe;
  private static final int DATABASE_VERSION = 10;
  
  private static final String DATABASE_CREATE = CREATE TABLE recipe ( 
 _id INTEGER PRIMARY KEY, title text not null, ingredients text not null, 
 instructions text not null, mealtime INTEGER not null, calories INTEGER not 
 null);;
  
  private static final String INITIAL_SETUP =
  INSERT INTO recipe (_id, title, instructions,ingredients, 
 mealtime, calories) 
  + VALUES (1, 'Triple Veggie Scramble','1. Chop all veggies and 
 set aside. Whisk eggs in bowl.\n2. Spray nonstick skillet with cooking spray 
 and saute veggies until soft.\n3. Add whisked eggs, cheese and dash salt and 
 pepper and cook until eggs are firm. \n4. Serve on toasted english muffin 
 with sliced pear on the side.',
  +'3 eggs (1 whole + 2 whites) \n1\\2 cup each chopped 
 tomatoes, spinach and mushrooms\n1 oz reduced fat shredded cheddar cheese\n1 
 Thomas Light Multigrain english muffin\nSmall pear, sliced.\nsalt/pepper to 
 taste', 1, 124);
  ;
  
  public RecipeDbHelper(Context context){
  super(context, DATABASE_NAME, null, DATABASE_VERSION);
  }
  
  public void clearReset(SQLiteDatabase db) {
  Log.w(Upgrading, Upgrading database from version);
  db.execSQL(DROP TABLE IF EXISTS + DATABASE_TABLE);
  onCreate(db);
  }
  
  @Override
  public void onCreate(SQLiteDatabase db){
  db.execSQL(DATABASE_CREATE);
  db.execSQL(INITIAL_SETUP);
  }
  
  @Override
  public void onUpgrade(SQLiteDatabase db, int oldVersion, int 
 newVersion){
  Log.w(Upgrading, Upgrading database from version  + 
 oldVersion +  to 
 + newVersion + , which will destroy all old data);
 db.execSQL(DROP TABLE IF EXISTS + DATABASE_TABLE);
 onCreate(db);
  }
 
 thanks again I truly appreciate it.
 
 Albert Rosa
 rosalb...@gmail.com
 alb...@albert-rosa.com
 (m) 718-825-7838
 (aim) albertrosa2000
 (gchat) rosalbert
 (gvoice) (646) 389-7672
 
 
 -- 
 Kostya Vasilyev -- http://kmansoft.wordpress.com
 
 -- 
 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


[android-developers] Re: Database shared by Activity and Service. What's the best approach?

2011-04-17 Thread bogde
Thanks for your suggestion Dianne. In addition to storing the values,
I need to show the evolution on a chart and possibly to export the
data in some format (like CSV) at a later time. With this in mind, I
guess the CP + sqlite back end approach is the easiest for me at this
time. Let's say I need to export the data stored the previous day, I'm
guessing it is easier for me to do a SQL query to select the data I
need to export than to manually extract the data from the binary
file.

Thanks again!

Bogdan



On Apr 17, 4:08 am, Dianne Hackborn hack...@android.com wrote:
 If you really care about performance, and all you are doing is reading two
 values and writing them over time, just appending this as binary data to a
 file would be far, far more efficient than using a SQLite database.



 On Sat, Apr 16, 2011 at 1:10 PM, bogde bogde...@gmail.com wrote:
  Thanks for the suggestion. I wasn't clear enough, I'm reading two
  analog values and store them over time; I store two values every ten
  seconds, so I need a database.

  I implemented a content provider and everything seems to work great so
  far. Actually, it worked pretty well before, except I used to get log
  entries from dalvikvm about sqlite errors (I'm ashamed to say I didn't
  keep the logs so I can't provide any more details). The application
  wasn't crashing or anything but being new to Android I wanted to make
  sure I'm at least using the best and safest methods.

  I have to update the charting functions to use the CP instead of
  direct database access and I'm done.

  Thank you all for your help!

  Bogdan

  On Apr 15, 10:03 am, Kostya Vasilyev kmans...@gmail.com wrote:
   Two values?

   Service running all the time?

   Just put them into static variables accessible from both your Service
   and Activity classes. Back up into shared preferences or a file, so you
   can reload the latest values if/when the service/process is killed.

   -- Kostya

   14.04.2011 11:17, bogde пишет:

Thank you both for taking the time to reply.

I read about ContentProvider and also read the thread you gave me. It
definitely looks like CP is the best approach for me. So I will have
the service write data to the database via CP, and the Activity will
use CP to display data. I wonder if this adds any unneeded overhead to
the whole application. The application runs on a WM8505 based Chinese
tablet with only 128 MB of RAM. The purpose of the entire hardware and
software is to record and display two values. I really hope the
hardware is good enough for the requirements.

Thanks again!

Bogdan

   --
   Kostya Vasilyev --http://kmansoft.wordpress.com

  --
  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

 --
 Dianne Hackborn
 Android framework engineer
 hack...@android.com

 Note: please don't send private questions to me, as I don't have time to
 provide private support, and so won't reply to such e-mails.  All such
 questions should be posted on public forums, where I and others can see and
 answer them.

-- 
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: Database shared by Activity and Service. What's the best approach?

2011-04-17 Thread Sahil Verma
Instead of repeatedly hitting the database to see if something is available, 
you could find some way for the service to send the new datum to the 
application when it is received from the external device.  I think this 
could be achieved with an explicit intent.  This allows the application to 
only update the chart when a new data point is available, but does not 
require the application to repeatedly poll a database (application is the 
observer in the observer design pattern here).  The service would still 
store the data to persistence (SQLite database for now or binary 
file later as Dianne recommended).  

-- 
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: Database shared by Activity and Service. What's the best approach?

2011-04-16 Thread bogde
Thanks for the suggestion. I wasn't clear enough, I'm reading two
analog values and store them over time; I store two values every ten
seconds, so I need a database.

I implemented a content provider and everything seems to work great so
far. Actually, it worked pretty well before, except I used to get log
entries from dalvikvm about sqlite errors (I'm ashamed to say I didn't
keep the logs so I can't provide any more details). The application
wasn't crashing or anything but being new to Android I wanted to make
sure I'm at least using the best and safest methods.

I have to update the charting functions to use the CP instead of
direct database access and I'm done.

Thank you all for your help!

Bogdan



On Apr 15, 10:03 am, Kostya Vasilyev kmans...@gmail.com wrote:
 Two values?

 Service running all the time?

 Just put them into static variables accessible from both your Service
 and Activity classes. Back up into shared preferences or a file, so you
 can reload the latest values if/when the service/process is killed.

 -- Kostya

 14.04.2011 11:17, bogde пишет:

  Thank you both for taking the time to reply.

  I read about ContentProvider and also read the thread you gave me. It
  definitely looks like CP is the best approach for me. So I will have
  the service write data to the database via CP, and the Activity will
  use CP to display data. I wonder if this adds any unneeded overhead to
  the whole application. The application runs on a WM8505 based Chinese
  tablet with only 128 MB of RAM. The purpose of the entire hardware and
  software is to record and display two values. I really hope the
  hardware is good enough for the requirements.

  Thanks again!

  Bogdan

 --
 Kostya Vasilyev --http://kmansoft.wordpress.com

-- 
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


Re: [android-developers] Re: Database shared by Activity and Service. What's the best approach?

2011-04-16 Thread Dianne Hackborn
If you really care about performance, and all you are doing is reading two
values and writing them over time, just appending this as binary data to a
file would be far, far more efficient than using a SQLite database.

On Sat, Apr 16, 2011 at 1:10 PM, bogde bogde...@gmail.com wrote:

 Thanks for the suggestion. I wasn't clear enough, I'm reading two
 analog values and store them over time; I store two values every ten
 seconds, so I need a database.

 I implemented a content provider and everything seems to work great so
 far. Actually, it worked pretty well before, except I used to get log
 entries from dalvikvm about sqlite errors (I'm ashamed to say I didn't
 keep the logs so I can't provide any more details). The application
 wasn't crashing or anything but being new to Android I wanted to make
 sure I'm at least using the best and safest methods.

 I have to update the charting functions to use the CP instead of
 direct database access and I'm done.

 Thank you all for your help!

 Bogdan



 On Apr 15, 10:03 am, Kostya Vasilyev kmans...@gmail.com wrote:
  Two values?
 
  Service running all the time?
 
  Just put them into static variables accessible from both your Service
  and Activity classes. Back up into shared preferences or a file, so you
  can reload the latest values if/when the service/process is killed.
 
  -- Kostya
 
  14.04.2011 11:17, bogde пишет:
 
   Thank you both for taking the time to reply.
 
   I read about ContentProvider and also read the thread you gave me. It
   definitely looks like CP is the best approach for me. So I will have
   the service write data to the database via CP, and the Activity will
   use CP to display data. I wonder if this adds any unneeded overhead to
   the whole application. The application runs on a WM8505 based Chinese
   tablet with only 128 MB of RAM. The purpose of the entire hardware and
   software is to record and display two values. I really hope the
   hardware is good enough for the requirements.
 
   Thanks again!
 
   Bogdan
 
  --
  Kostya Vasilyev --http://kmansoft.wordpress.com

 --
 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




-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

-- 
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: Database shared by Activity and Service. What's the best approach?

2011-04-15 Thread bogde
Thank you both for taking the time to reply.

I read about ContentProvider and also read the thread you gave me. It
definitely looks like CP is the best approach for me. So I will have
the service write data to the database via CP, and the Activity will
use CP to display data. I wonder if this adds any unneeded overhead to
the whole application. The application runs on a WM8505 based Chinese
tablet with only 128 MB of RAM. The purpose of the entire hardware and
software is to record and display two values. I really hope the
hardware is good enough for the requirements.

Thanks again!

Bogdan


On Apr 14, 7:58 am, gjs garyjamessi...@gmail.com wrote:
 Hi,

 +1 contentprovider.

 This thread is possibly worth reading -

 http://groups.google.com/group/android-developers/browse_thread/threa...

 Regards

 On Apr 14, 2:22 pm, Nikolay Elenkov nikolay.elen...@gmail.com wrote:

  On Tue, Apr 12, 2011 at 5:32 PM, bogde bogde...@gmail.com wrote:
    My question is, what would be the best way to
   accomplish this? How to share the database between the service that
   runs all the time and an activity?

  Content provider?

-- 
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


Re: [android-developers] Re: Database shared by Activity and Service. What's the best approach?

2011-04-15 Thread Kostya Vasilyev

Two values?

Service running all the time?

Just put them into static variables accessible from both your Service 
and Activity classes. Back up into shared preferences or a file, so you 
can reload the latest values if/when the service/process is killed.


-- Kostya

14.04.2011 11:17, bogde пишет:

Thank you both for taking the time to reply.

I read about ContentProvider and also read the thread you gave me. It
definitely looks like CP is the best approach for me. So I will have
the service write data to the database via CP, and the Activity will
use CP to display data. I wonder if this adds any unneeded overhead to
the whole application. The application runs on a WM8505 based Chinese
tablet with only 128 MB of RAM. The purpose of the entire hardware and
software is to record and display two values. I really hope the
hardware is good enough for the requirements.

Thanks again!

Bogdan




--
Kostya Vasilyev -- http://kmansoft.wordpress.com

--
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: Database shared by Activity and Service. What's the best approach?

2011-04-14 Thread lbendlin
Another option is to open the database in the launch activity, and then keep 
a reference to it in the application object so that it can be used from 
anywhere.  Close the database in the onDestroy of the launcher activity.

-- 
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: Database shared by Activity and Service. What's the best approach?

2011-04-13 Thread gjs
Hi,

+1 contentprovider.

This thread is possibly worth reading -

http://groups.google.com/group/android-developers/browse_thread/thread/20d8cbf7bf88f6d9

Regards

On Apr 14, 2:22 pm, Nikolay Elenkov nikolay.elen...@gmail.com wrote:
 On Tue, Apr 12, 2011 at 5:32 PM, bogde bogde...@gmail.com wrote:
   My question is, what would be the best way to
  accomplish this? How to share the database between the service that
  runs all the time and an activity?

 Content provider?

-- 
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: database and maps

2011-03-23 Thread Piyush Hari
Putting latitudes and longitudes is one way. Putting just the address
and geocoding it before displaying on map is another. The caveat with
the latter approach is that geocoding everytime you retrieve data is
costly. Since latitudes/longitudes associated with addresses do not
change, it is best to store lat/lng in dB after geocoding the address
at the time of inserting the entry in db.

On Mar 22, 4:48 pm, sunny sunnykradi...@gmail.com wrote:
 in my project i need to take entries frm Db and show location on map

 is der any simpler approach den puttin latitude and longitude in table

-- 
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: database and maps

2011-03-23 Thread sunny
@piyush thanx a lot . I knw this is bit too much do u hav links to sm
tuts regarding dis .I have been at it fr a while..


On Mar 23, 12:33 pm, Piyush Hari piyush.h...@gmail.com wrote:
 Putting latitudes and longitudes is one way. Putting just the address
 and geocoding it before displaying on map is another. The caveat with
 the latter approach is that geocoding everytime you retrieve data is
 costly. Since latitudes/longitudes associated with addresses do not
 change, it is best to store lat/lng in dB after geocoding the address
 at the time of inserting the entry in db.

 On Mar 22, 4:48 pm, sunny sunnykradi...@gmail.com wrote:







  in my project i need to take entries frm Db and show location on map

  is der any simpler approach den puttin latitude and longitude in table

-- 
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: Database Remote Access

2010-12-26 Thread Russell DuRoss
Amazon is starting a cloud based service - maybe that would help.
Here's a link to get you started with info on it.
http://mobileoffice.about.com/b/2010/12/12/expect-a-lot-more-mobile-cloud-apps-soon-amazon-intros-mobile-sdks-for-iphone-android.htm

On Dec 23, 5:48 pm, kennedyximenes kennedy.xime...@gmail.com wrote:
 Hi,

 I am developing an Android App and I need to connect to read and
 retrieve data from a remote database.

 On the one side I have a SQL Server Database and on the other side I
 have my Android application. I would like a tutorial or a practical
 example describing all processes and how to do that.

 Thank you for any help.

-- 
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: Database Remote Access

2010-12-25 Thread Hal
You may want to look into the Jt framework for Android.
It supports Web services (Resful) and Data Access Object (DAOs). You
just need
to use these pieces for your application:

a) Java Pattern Oriented Framework, An application of the Messaging
Design Pattern
IBM Technical Library
http://www.ibm.com/developerworks/webservices/library/ws-designpattern/index.html

b) Messaging Design Pattern (MDP) and pattern implementation -
Published in the 17th conference on Pattern Languages of Programs
(PLoP 2010).
https://jt.dev.java.net/files/documents/5553/150311/designPatterns.pdf



On Dec 23, 5:48 pm, kennedyximenes kennedy.xime...@gmail.com wrote:
 Hi,

 I am developing an Android App and I need to connect to read and
 retrieve data from a remote database.

 On the one side I have a SQL Server Database and on the other side I
 have my Android application. I would like a tutorial or a practical
 example describing all processes and how to do that.

 Thank you for any help.

-- 
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: Database storage filling and securing

2010-12-25 Thread Hal
A combination of secure web services and Data Access Objects (DAOs)
should be able to provide this functionality:


For additional information please refer to the following URLs:

a) Java Pattern Oriented Framework, An application of the Messaging
Design Pattern
IBM Technical Library
http://www.ibm.com/developerworks/webservices/library/ws-designpattern/index.html

b) Messaging Design Pattern (MDP) and pattern implementation -
Published in the 17th conference on Pattern Languages of Programs
(PLoP 2010).
https://jt.dev.java.net/files/documents/5553/150311/designPatterns.pdf

I hope this helps.

On Dec 24, 7:32 am, Nikola nikola1...@gmail.com wrote:
 Hi,

 I have large amount of data that I should query and display to user.

 What are recommended strategies for:

 1) filling database (I would like to do it outside phone and just provided
 it somehow)

 2) secure database so it isn't readable unless you are using app

 Thanks.

 --
 God is Real, unless declared Integer.
 J. Allan Toogood, FORTRAN programmer

-- 
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: Database Remote Access

2010-12-24 Thread Federico Paolinelli
On 23 Dic, 23:48, kennedyximenes kennedy.xime...@gmail.com wrote:
 Hi,

 I am developing an Android App and I need to connect to read and
 retrieve data from a remote database.

 On the one side I have a SQL Server Database and on the other side I
 have my Android application. I would like a tutorial or a practical
 example describing all processes and how to do that.

 Thank you for any help.


I don't have any tutorial, but this is a quite common asked question.
The best practice seems to be to put some webservice(ish) stuff
between your android app and the dbms, and expose an interface to do
whatever you want to do with the dbms.

Hope this helps,

Federico

-- 
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: database difficulties

2010-09-19 Thread Tim
Dear Damien,

You may be interested in looking at our MobiForms Developer.
MobiForms is a rapid mobile application development tool ideal for
creating professional business database apps.

MobiForms can connect directly to a host of industry standard
databases such as Oracle and SQL Server (using a secure Wi-Fi network
or phone network with a private APN) or for partially disconnected
apps using the MobiForms Sync Server for offline buffering and online
synchronisation.

MobiForms is a proven technology used by hundreds of customers all
over the world to create field service, inspection, stock control and
CRM apps etc.

MobiForms was the world's first rapid application development tool
designed for specifically for Google Android smartphones.
Additionally, the same app will run on other platforms like Windows
Mobile without reconfiguration.

In one compact solution MobiForms replaces the need to download,
configure and learn 100s MB of diverse tools such as Eclipse, the
Android SDK, Droid Draw, Java or XML etc.

We have just released MobiForms 5.03 now with native Google Android
support for the camera and GPS integration.  Ideal for ideal for
adding photos to inspection reports and location capture to field
service or lone worker apps.

For more information please go to: http://www.mobiforms.com.

Kind regards,

Tim @ MobiForms


Damien wrote:
 Hi All,
 I am just starting with Android development.  I am looking to port one
 of my iPhone apps to Android as a project to get going.  I have an
 exiting database that I would like to use.  So I have subclassed
 SQLiteOpenHelper and I open the database for writing then close it
 this should create the database, then I copy the database I have from
 my assts directory over the freshly created database file.

 It turns out my directory /data/data/com.mycompany.MyApplication/
 databases does not exist.  Ok so I try to crate it with File.mkdirs()
 and it laughs at me and does not create the directory.

 If anyone has had an issue like this I would love to hear how it was
 solved.  The phone I am using is a HTC Desire running Android 2.1
 update 1.

 Regards
 Damien

-- 
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: Database transaction help needed.

2010-08-24 Thread tatebn
That just makes perfect sense.  Thanks.  I ended up adding a second
constructor to the table access wrappers that accepts both the context
and an already open database connection.  Works great.

On Aug 24, 3:36 pm, Kostya Vasilyev kmans...@gmail.com wrote:
 Transactions are per-connection. That's on purpose, so a connection sees all
 changes made by others only once are of them are complete.

 Either switch to one connection, or don't use transactions, preferably both.

 --
 Kostya Vasilyev --http://kmansoft.wordpress.com

 24.08.2010 23:21 пользователь Kim Damevin kdame...@gmail.com написал:

 Hi,

 Do you call getWriteableDatabase twice ? because you shouldn't.
 It should be the same SQLiteDatabase object or you have to end the
 transaction from the first one before you start a new one.

 Kim

 On Tue, Aug 24, 2010 at 9:09 PM, tatebn brandonnt...@gmail.com wrote:

  I'm using transaction...



-- 
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: Database folder

2010-06-14 Thread Pinheiro
Thanks Mark!
The problem is that that only works if the database already exists.
I guess I could create a dummy database just to see where it is
created but it's a nasty kludge.

-- 
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: Database folder

2010-06-14 Thread Pinheiro
It worked! Thanks, Mark!
The documentation lead me to believe that it would only work if the
database is *already* created but that it's not true.

-- 
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: Database folder

2010-06-14 Thread Zsolt Vasvari
Couldn't you ship your database as an asset in the .apk?  It's the
same net effect, but perhaps you could get away with not requiring the
INTERNET permission.

On Jun 15, 3:29 am, Pinheiro rui.c.pinhe...@gmail.com wrote:
 It worked! Thanks, Mark!
 The documentation lead me to believe that it would only work if the
 database is *already* created but that it's not true.

-- 
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


Re: [android-developers] Re: Database insertion timings

2010-04-14 Thread Alok Kulkarni
@Walter, i tried that out. Instead of sb.toString() , i put the insert
statement string over there with Compile statement format..
Its taking *27* *seconds *!!
The database schema is as follows
Table *Artist*
id Integer Primary Key
name nvarchar(200)

Table *Album*
name nvarchar(200)
label nvarchar(200)
multiple_artists integer
artist_id integer
id integer Primary Key

Table *Songs*
artist_id integer
album_id integer
id integer Primary Key
name nvarchar(200)


On Mon, Apr 12, 2010 at 9:26 PM, Dave Johnston john...@gmail.com wrote:

 On Apr 12, 7:50 am, Alok Kulkarni kulsu...@gmail.com wrote:
  Hi,
  I am inserting around 7000 to 8000 records in my database having 4 tables
  each having 3 to 4 columns.Its taking me around 22 seconds to do the
  insertion which is i think is too long.

 Can you post the schema of the database you're inserting into?

 -d

 --
 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.comandroid-developers%2bunsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en

 To unsubscribe, reply using remove me as the subject.


-- 
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: Database insertion timings

2010-04-14 Thread Walter
Could you post your code here. compileStatement is usually for batch
reusable SQL statement, It's kind of best practice to use this in this
case. no reason that it's slower than normal SQL.


On Apr 14, 1:17 am, Alok Kulkarni kulsu...@gmail.com wrote:
 @Walter, i tried that out. Instead of sb.toString() , it the insert
 statement string over there with Compile statement format..
 Its taking *27* *seconds *!!
 The database schema is as follows
 Table *Artist*
 id Integer Primary Key
 name nvarchar(200)

 Table *Album*
 name nvarchar(200)
 label nvarchar(200)
 multiple_artists integer
 artist_id integer
 id integer Primary Key

 Table *Songs*
 artist_id integer
 album_id integer
 id integer Primary Key
 name nvarchar(200)



 On Mon, Apr 12, 2010 at 9:26 PM, Dave Johnston john...@gmail.com wrote:
  On Apr 12, 7:50 am, Alok Kulkarni kulsu...@gmail.com wrote:
   Hi,
   I am inserting around 7000 to 8000 records in my database having 4 tables
   each having 3 to 4 columns.Its taking me around 22 seconds to do the
   insertion which is i think is too long.

  Can you post the schema of the database you're inserting into?

  -d

  --
  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.comandroid-developers%2Bunsubs 
  cr...@googlegroups.com
  For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en

  To unsubscribe, reply using remove me as the subject.

-- 
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: Database insertion timings

2010-04-13 Thread Bob Kerns
It is often better to insert all the data and THEN create the indexes.
I couldn't tell you about Sqlite.

You may want to create the primary index, but create all the other
indexes later.

On Apr 12, 5:33 pm, Zsolt Vasvari zvasv...@gmail.com wrote:
 No, database writing is extremely slow especially with many indecies.

 In my app, I am getting maybe 10 insers a seconds into a table with 20
 columns and 15 indecies.  As my app is probably 99.9% reads, I didn't
 try optimizing the writes too much, not sure if it's even possible.

 On Apr 13, 12:33 am, Yahel kaye...@gmail.com wrote:



  Ok, you are right if the pre and the iphone are 10x faster, it can't
  be right.

  I don't see anything wrong in your code, so only two things come to
  mind :

  - Instead of using ContentValues, try to create an insert sql
  statement and send it to via SQLiteDatabase.execSQL to see if there is
  any improvement
  - Maybe it's not the database writing that is slow but the reading
  from wherever your getting the data ?

  Yahel

  On 12 avr, 12:31, Alok Kulkarni kulsu...@gmail.com wrote:

   Ok,
   @Yahel:- For the insertion of same records on a Palm device(Say Palm Pre) 
   ,
   its taking 3 seconds..
   On an IPhone , its taking 1 or  2 seconds..
   Here is an example of what i am doing..
   private Boolean addAlbumDB(int AlbumId, String Name, String Label,
               int MultipleArtists, int ArtistId) {
           long result = -1;

           try {

               ContentValues initialValues = new ContentValues();
               initialValues.put(KEY_ID, AlbumId);
               initialValues.put(KEY_NAME, Name);
               initialValues.put(KEY_LABEL, Label);
               initialValues.put(KEY_ARTIST_ID, ArtistId);
               initialValues.put(KEY_MULTIPLE_ARTISTS, MultipleArtists);

                result = db.insert(DATABASE_TABLE, null, initialValues);

           } catch (Exception e) {
               Log.i(Exception in addAlbumDB,  + e.toString());
               return false;
           }

           if (result == -1)
               return false;
           return true;
       }

   The above function is called for around 2000 times..
   Similarly there are 2 3 more functions for other tables.
   Thanks,
   Alok.

   On Mon, Apr 12, 2010 at 2:33 PM, Michael Rueger 
   mike.rue...@gmail.comwrote:

On 4/12/2010 10:59 AM, Yahel wrote:

Hi Alok,

Posting some logic, or some sql would help us see if you are missing
something :)

(excessive) use of indices comes to mind :-)

Michael

Yahel

On 12 avr, 08:50, Alok Kulkarnikulsu...@gmail.com  wrote:

Hi,
I am inserting around 7000 to 8000 records in my database having 4 
tables
each having 3 to 4 columns.Its taking me around 22 seconds to do the
insertion which is i think is too long. I am using transaction while
doing
this without which its taking around 55 seconds.
According to SQLite documentation , inserting 1 records in a 
database
takes time  around 2 to 3 seconds.
Am i missing something , or is the behaviour correct?
Thanks,
Alok

--
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.comandroid-developers%2Bunsubs
 cr...@googlegroups.com
For more options, visit this group at
   http://groups.google.com/group/android-developers?hl=en

To unsubscribe, reply using remove me as the subject.- Hide quoted 
text -

  - Show quoted text -

-- 
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


Re: [android-developers] Re: Database insertion timings

2010-04-13 Thread Alok Kulkarni
I do not have any indices for my tables at all.
Each of the tables Artist, Albumn and Songs has 4,5,5 columns respectively.
Using Raw query as Yahel said improves the speed to some extent . Inserting
7000 records takes 18 seconds instead of 22 but thats not much as in total ,
i am going to insert 3 to 4 entries , which will take hell lot of
time..
Using raw queries is not much helpful as the data itself might contain
quotes and double quotes.
Thanks ,
Alok.

On Tue, Apr 13, 2010 at 11:32 AM, Bob Kerns r...@acm.org wrote:

 It is often better to insert all the data and THEN create the indexes.
 I couldn't tell you about Sqlite.

 You may want to create the primary index, but create all the other
 indexes later.

 On Apr 12, 5:33 pm, Zsolt Vasvari zvasv...@gmail.com wrote:
  No, database writing is extremely slow especially with many indecies.
 
  In my app, I am getting maybe 10 insers a seconds into a table with 20
  columns and 15 indecies.  As my app is probably 99.9% reads, I didn't
  try optimizing the writes too much, not sure if it's even possible.
 
  On Apr 13, 12:33 am, Yahel kaye...@gmail.com wrote:
 
 
 
   Ok, you are right if the pre and the iphone are 10x faster, it can't
   be right.
 
   I don't see anything wrong in your code, so only two things come to
   mind :
 
   - Instead of using ContentValues, try to create an insert sql
   statement and send it to via SQLiteDatabase.execSQL to see if there is
   any improvement
   - Maybe it's not the database writing that is slow but the reading
   from wherever your getting the data ?
 
   Yahel
 
   On 12 avr, 12:31, Alok Kulkarni kulsu...@gmail.com wrote:
 
Ok,
@Yahel:- For the insertion of same records on a Palm device(Say Palm
 Pre) ,
its taking 3 seconds..
On an IPhone , its taking 1 or  2 seconds..
Here is an example of what i am doing..
private Boolean addAlbumDB(int AlbumId, String Name, String Label,
int MultipleArtists, int ArtistId) {
long result = -1;
 
try {
 
ContentValues initialValues = new ContentValues();
initialValues.put(KEY_ID, AlbumId);
initialValues.put(KEY_NAME, Name);
initialValues.put(KEY_LABEL, Label);
initialValues.put(KEY_ARTIST_ID, ArtistId);
initialValues.put(KEY_MULTIPLE_ARTISTS, MultipleArtists);
 
 result = db.insert(DATABASE_TABLE, null, initialValues);
 
} catch (Exception e) {
Log.i(Exception in addAlbumDB,  + e.toString());
return false;
}
 
if (result == -1)
return false;
return true;
}
 
The above function is called for around 2000 times..
Similarly there are 2 3 more functions for other tables.
Thanks,
Alok.
 
On Mon, Apr 12, 2010 at 2:33 PM, Michael Rueger 
 mike.rue...@gmail.comwrote:
 
 On 4/12/2010 10:59 AM, Yahel wrote:
 
 Hi Alok,
 
 Posting some logic, or some sql would help us see if you are
 missing
 something :)
 
 (excessive) use of indices comes to mind :-)
 
 Michael
 
 Yahel
 
 On 12 avr, 08:50, Alok Kulkarnikulsu...@gmail.com  wrote:
 
 Hi,
 I am inserting around 7000 to 8000 records in my database having
 4 tables
 each having 3 to 4 columns.Its taking me around 22 seconds to do
 the
 insertion which is i think is too long. I am using transaction
 while
 doing
 this without which its taking around 55 seconds.
 According to SQLite documentation , inserting 1 records in a
 database
 takes time  around 2 to 3 seconds.
 Am i missing something , or is the behaviour correct?
 Thanks,
 Alok
 
 --
 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.comandroid-developers%2bunsubscr...@googlegroups.comandroid-developers%2Bunsubs
 cr...@googlegroups.com
 For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
 
 To unsubscribe, reply using remove me as the subject.- Hide
 quoted text -
 
   - Show quoted text -

 --
 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.comandroid-developers%2bunsubscr...@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, 

Re: [android-developers] Re: Database insertion timings

2010-04-13 Thread Alok Kulkarni
@mobDev, Ending transaction

On Tue, Apr 13, 2010 at 12:59 PM, Alok Kulkarni kulsu...@gmail.com wrote:

 I do not have any indices for my tables at all.
 Each of the tables Artist, Albumn and Songs has 4,5,5 columns respectively.
 Using Raw query as Yahel said improves the speed to some extent . Inserting
 7000 records takes 18 seconds instead of 22 but thats not much as in total ,
 i am going to insert 3 to 4 entries , which will take hell lot of
 time..
 Using raw queries is not much helpful as the data itself might contain
 quotes and double quotes.
 Thanks ,
 Alok.


 On Tue, Apr 13, 2010 at 11:32 AM, Bob Kerns r...@acm.org wrote:

 It is often better to insert all the data and THEN create the indexes.
 I couldn't tell you about Sqlite.

 You may want to create the primary index, but create all the other
 indexes later.

 On Apr 12, 5:33 pm, Zsolt Vasvari zvasv...@gmail.com wrote:
  No, database writing is extremely slow especially with many indecies.
 
  In my app, I am getting maybe 10 insers a seconds into a table with 20
  columns and 15 indecies.  As my app is probably 99.9% reads, I didn't
  try optimizing the writes too much, not sure if it's even possible.
 
  On Apr 13, 12:33 am, Yahel kaye...@gmail.com wrote:
 
 
 
   Ok, you are right if the pre and the iphone are 10x faster, it can't
   be right.
 
   I don't see anything wrong in your code, so only two things come to
   mind :
 
   - Instead of using ContentValues, try to create an insert sql
   statement and send it to via SQLiteDatabase.execSQL to see if there is
   any improvement
   - Maybe it's not the database writing that is slow but the reading
   from wherever your getting the data ?
 
   Yahel
 
   On 12 avr, 12:31, Alok Kulkarni kulsu...@gmail.com wrote:
 
Ok,
@Yahel:- For the insertion of same records on a Palm device(Say Palm
 Pre) ,
its taking 3 seconds..
On an IPhone , its taking 1 or  2 seconds..
Here is an example of what i am doing..
private Boolean addAlbumDB(int AlbumId, String Name, String Label,
int MultipleArtists, int ArtistId) {
long result = -1;
 
try {
 
ContentValues initialValues = new ContentValues();
initialValues.put(KEY_ID, AlbumId);
initialValues.put(KEY_NAME, Name);
initialValues.put(KEY_LABEL, Label);
initialValues.put(KEY_ARTIST_ID, ArtistId);
initialValues.put(KEY_MULTIPLE_ARTISTS,
 MultipleArtists);
 
 result = db.insert(DATABASE_TABLE, null,
 initialValues);
 
} catch (Exception e) {
Log.i(Exception in addAlbumDB,  + e.toString());
return false;
}
 
if (result == -1)
return false;
return true;
}
 
The above function is called for around 2000 times..
Similarly there are 2 3 more functions for other tables.
Thanks,
Alok.
 
On Mon, Apr 12, 2010 at 2:33 PM, Michael Rueger 
 mike.rue...@gmail.comwrote:
 
 On 4/12/2010 10:59 AM, Yahel wrote:
 
 Hi Alok,
 
 Posting some logic, or some sql would help us see if you are
 missing
 something :)
 
 (excessive) use of indices comes to mind :-)
 
 Michael
 
 Yahel
 
 On 12 avr, 08:50, Alok Kulkarnikulsu...@gmail.com  wrote:
 
 Hi,
 I am inserting around 7000 to 8000 records in my database having
 4 tables
 each having 3 to 4 columns.Its taking me around 22 seconds to do
 the
 insertion which is i think is too long. I am using transaction
 while
 doing
 this without which its taking around 55 seconds.
 According to SQLite documentation , inserting 1 records in a
 database
 takes time  around 2 to 3 seconds.
 Am i missing something , or is the behaviour correct?
 Thanks,
 Alok
 
 --
 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.comandroid-developers%2bunsubscr...@googlegroups.comandroid-developers%2Bunsubs
 cr...@googlegroups.com
 For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
 
 To unsubscribe, reply using remove me as the subject.- Hide
 quoted text -
 
   - Show quoted text -

 --
 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.comandroid-developers%2bunsubscr...@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 

Re: [android-developers] Re: Database insertion timings

2010-04-13 Thread Alok Kulkarni
@mobDev, I have followed some links , example
http://www.higherpass.com/Android/Tutorials/Accessing-Data-With-Android-Cursors/3/
where they were doing setTransactionSuccessful before ending transaction.
Removing that statement does not have an effect.
Even if i do say
String tempName = Artist;
String tempVal = Enrique;
int tempId = 0;
for(i = 0;i 7000;i++)
{
tempId++;
addArtistDB(tempID,tempName,tempVal1);
}
It takes 20 seconds .So there is not much time required for accessing the
data i want to put into database. The actual insertion itself is taking so
much time.
As Sqlite is native to Android , i assume it must be fast enough.
One more thing , Same amount of insertions on a Windows Mobile Device ,
using a Third Party SQLite DLL , its taking 5 to 6 seconds..
Its not that i am blaming android , but i am getting frustrated now :( :(

Thanks ,
Alok.
On Tue, Apr 13, 2010 at 1:07 PM, Alok Kulkarni kulsu...@gmail.com wrote:

 @mobDev, Ending transaction

 On Tue, Apr 13, 2010 at 12:59 PM, Alok Kulkarni kulsu...@gmail.comwrote:

 I do not have any indices for my tables at all.
 Each of the tables Artist, Albumn and Songs has 4,5,5 columns
 respectively.
 Using Raw query as Yahel said improves the speed to some extent .
 Inserting 7000 records takes 18 seconds instead of 22 but thats not much as
 in total , i am going to insert 3 to 4 entries , which will take
 hell lot of time..
 Using raw queries is not much helpful as the data itself might contain
 quotes and double quotes.
 Thanks ,
 Alok.


 On Tue, Apr 13, 2010 at 11:32 AM, Bob Kerns r...@acm.org wrote:

 It is often better to insert all the data and THEN create the indexes.
 I couldn't tell you about Sqlite.

 You may want to create the primary index, but create all the other
 indexes later.

 On Apr 12, 5:33 pm, Zsolt Vasvari zvasv...@gmail.com wrote:
  No, database writing is extremely slow especially with many indecies.
 
  In my app, I am getting maybe 10 insers a seconds into a table with 20
  columns and 15 indecies.  As my app is probably 99.9% reads, I didn't
  try optimizing the writes too much, not sure if it's even possible.
 
  On Apr 13, 12:33 am, Yahel kaye...@gmail.com wrote:
 
 
 
   Ok, you are right if the pre and the iphone are 10x faster, it can't
   be right.
 
   I don't see anything wrong in your code, so only two things come to
   mind :
 
   - Instead of using ContentValues, try to create an insert sql
   statement and send it to via SQLiteDatabase.execSQL to see if there
 is
   any improvement
   - Maybe it's not the database writing that is slow but the reading
   from wherever your getting the data ?
 
   Yahel
 
   On 12 avr, 12:31, Alok Kulkarni kulsu...@gmail.com wrote:
 
Ok,
@Yahel:- For the insertion of same records on a Palm device(Say
 Palm Pre) ,
its taking 3 seconds..
On an IPhone , its taking 1 or  2 seconds..
Here is an example of what i am doing..
private Boolean addAlbumDB(int AlbumId, String Name, String Label,
int MultipleArtists, int ArtistId) {
long result = -1;
 
try {
 
ContentValues initialValues = new ContentValues();
initialValues.put(KEY_ID, AlbumId);
initialValues.put(KEY_NAME, Name);
initialValues.put(KEY_LABEL, Label);
initialValues.put(KEY_ARTIST_ID, ArtistId);
initialValues.put(KEY_MULTIPLE_ARTISTS,
 MultipleArtists);
 
 result = db.insert(DATABASE_TABLE, null,
 initialValues);
 
} catch (Exception e) {
Log.i(Exception in addAlbumDB,  + e.toString());
return false;
}
 
if (result == -1)
return false;
return true;
}
 
The above function is called for around 2000 times..
Similarly there are 2 3 more functions for other tables.
Thanks,
Alok.
 
On Mon, Apr 12, 2010 at 2:33 PM, Michael Rueger 
 mike.rue...@gmail.comwrote:
 
 On 4/12/2010 10:59 AM, Yahel wrote:
 
 Hi Alok,
 
 Posting some logic, or some sql would help us see if you are
 missing
 something :)
 
 (excessive) use of indices comes to mind :-)
 
 Michael
 
 Yahel
 
 On 12 avr, 08:50, Alok Kulkarnikulsu...@gmail.com  wrote:
 
 Hi,
 I am inserting around 7000 to 8000 records in my database
 having 4 tables
 each having 3 to 4 columns.Its taking me around 22 seconds to
 do the
 insertion which is i think is too long. I am using transaction
 while
 doing
 this without which its taking around 55 seconds.
 According to SQLite documentation , inserting 1 records in
 a database
 takes time  around 2 to 3 seconds.
 Am i missing something , or is the behaviour correct?
 Thanks,
 Alok
 
 --
 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] Re: Database insertion timings

2010-04-13 Thread Walter
Use SQLiteStatement.compileStatement, I do believe it should be faster
with my 10 years database programming  experience, though I didn't
test, Let  me know if you have a result.

Here is some code from my Remote RDP program for importing data to the
table:

SQLiteStatement sls = 
db.compileStatement(sb.toString());

while ((line = br.readLine()) != null) {
st.reset(line, delimiter);
for (int i = 0; i  columns; i++) {
String value = st.next();
if (value == null){
value   = ;
}
sls.bindString(i + 1, value);
}
sls.execute();
}



On Apr 13, 1:47 am, Alok Kulkarni kulsu...@gmail.com wrote:
 @mobDev, I have followed some links , 
 examplehttp://www.higherpass.com/Android/Tutorials/Accessing-Data-With-Andro...
 where they were doing setTransactionSuccessful before ending transaction.
 Removing that statement does not have an effect.
 Even if i do say
 String tempName = Artist;
 String tempVal = Enrique;
 int tempId = 0;
 for(i = 0;i 7000;i++)
 {
 tempId++;
 addArtistDB(tempID,tempName,tempVal1);}

 It takes 20 seconds .So there is not much time required for accessing the
 data i want to put into database. The actual insertion itself is taking so
 much time.
 As Sqlite is native to Android , i assume it must be fast enough.
 One more thing , Same amount of insertions on a Windows Mobile Device ,
 using a Third Party SQLite DLL , its taking 5 to 6 seconds..
 Its not that i am blaming android , but i am getting frustrated now :( :(

 Thanks ,
 Alok.



 On Tue, Apr 13, 2010 at 1:07 PM, Alok Kulkarni kulsu...@gmail.com wrote:
  @mobDev, Ending transaction

  On Tue, Apr 13, 2010 at 12:59 PM, Alok Kulkarni kulsu...@gmail.comwrote:

  I do not have any indices for my tables at all.
  Each of the tables Artist, Albumn and Songs has 4,5,5 columns
  respectively.
  Using Raw query as Yahel said improves the speed to some extent .
  Inserting 7000 records takes 18 seconds instead of 22 but thats not much as
  in total , i am going to insert 3 to 4 entries , which will take
  hell lot of time..
  Using raw queries is not much helpful as the data itself might contain
  quotes and double quotes.
  Thanks ,
  Alok.

  On Tue, Apr 13, 2010 at 11:32 AM, Bob Kerns r...@acm.org wrote:

  It is often better to insert all the data and THEN create the indexes.
  I couldn't tell you about Sqlite.

  You may want to create the primary index, but create all the other
  indexes later.

  On Apr 12, 5:33 pm, Zsolt Vasvari zvasv...@gmail.com wrote:
   No, database writing is extremely slow especially with many indecies.

   In my app, I am getting maybe 10 insers a seconds into a table with 20
   columns and 15 indecies.  As my app is probably 99.9% reads, I didn't
   try optimizing the writes too much, not sure if it's even possible.

   On Apr 13, 12:33 am, Yahel kaye...@gmail.com wrote:

Ok, you are right if the pre and the iphone are 10x faster, it can't
be right.

I don't see anything wrong in your code, so only two things come to
mind :

- Instead of using ContentValues, try to create an insert sql
statement and send it to via SQLiteDatabase.execSQL to see if there
  is
any improvement
- Maybe it's not the database writing that is slow but the reading
from wherever your getting the data ?

Yahel

On 12 avr, 12:31, Alok Kulkarni kulsu...@gmail.com wrote:

 Ok,
 @Yahel:- For the insertion of same records on a Palm device(Say
  Palm Pre) ,
 its taking 3 seconds..
 On an IPhone , its taking 1 or  2 seconds..
 Here is an example of what i am doing..
 private Boolean addAlbumDB(int AlbumId, String Name, String Label,
             int MultipleArtists, int ArtistId) {
         long result = -1;

         try {

             ContentValues initialValues = new ContentValues();
             initialValues.put(KEY_ID, AlbumId);
             initialValues.put(KEY_NAME, Name);
             initialValues.put(KEY_LABEL, Label);
             initialValues.put(KEY_ARTIST_ID, ArtistId);
             initialValues.put(KEY_MULTIPLE_ARTISTS,
  MultipleArtists);

              result = db.insert(DATABASE_TABLE, null,
  initialValues);

         } catch (Exception e) {
             Log.i(Exception in addAlbumDB,  + e.toString());
             return false;
         }

         if (result == -1)
             return false;
         return true;
     }

 The above function is called for around 2000 times..
 Similarly there are 2 3 more functions for other tables.
 Thanks,
 Alok.

 On Mon, Apr 

[android-developers] Re: Database insertion timings

2010-04-13 Thread Dave Johnston
On Apr 12, 7:50 am, Alok Kulkarni kulsu...@gmail.com wrote:
 Hi,
 I am inserting around 7000 to 8000 records in my database having 4 tables
 each having 3 to 4 columns.Its taking me around 22 seconds to do the
 insertion which is i think is too long.

Can you post the schema of the database you're inserting into?

-d

-- 
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

To unsubscribe, reply using remove me as the subject.


[android-developers] Re: Database insertion timings

2010-04-12 Thread Yahel
Hi Alok,

Posting some logic, or some sql would help us see if you are missing
something :)

Yahel

On 12 avr, 08:50, Alok Kulkarni kulsu...@gmail.com wrote:
 Hi,
 I am inserting around 7000 to 8000 records in my database having 4 tables
 each having 3 to 4 columns.Its taking me around 22 seconds to do the
 insertion which is i think is too long. I am using transaction while doing
 this without which its taking around 55 seconds.
 According to SQLite documentation , inserting 1 records in a database
 takes time  around 2 to 3 seconds.
 Am i missing something , or is the behaviour correct?
 Thanks,
 Alok

-- 
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

To unsubscribe, reply using remove me as the subject.


[android-developers] Re: Database insertion timings

2010-04-12 Thread Yahel
 According to SQLite documentation , inserting 1 records in a database
 takes time  around 2 to 3 seconds.

Did you take into account that the sqlite documentation is probably
taking a standard PC (2GHz, 1GB of ram) as its default value not a
mobile device with a quarter of the resources ?

Yahel

-- 
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

To unsubscribe, reply using remove me as the subject.


Re: [android-developers] Re: Database insertion timings

2010-04-12 Thread Michael Rueger

On 4/12/2010 10:59 AM, Yahel wrote:

Hi Alok,

Posting some logic, or some sql would help us see if you are missing
something :)


(excessive) use of indices comes to mind :-)

Michael



Yahel

On 12 avr, 08:50, Alok Kulkarnikulsu...@gmail.com  wrote:

Hi,
I am inserting around 7000 to 8000 records in my database having 4 tables
each having 3 to 4 columns.Its taking me around 22 seconds to do the
insertion which is i think is too long. I am using transaction while doing
this without which its taking around 55 seconds.
According to SQLite documentation , inserting 1 records in a database
takes time  around 2 to 3 seconds.
Am i missing something , or is the behaviour correct?
Thanks,
Alok




--
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

To unsubscribe, reply using remove me as the subject.


Re: [android-developers] Re: Database insertion timings

2010-04-12 Thread Alok Kulkarni
Ok,
@Yahel:- For the insertion of same records on a Palm device(Say Palm Pre) ,
its taking 3 seconds..
On an IPhone , its taking 1 or  2 seconds..
Here is an example of what i am doing..
private Boolean addAlbumDB(int AlbumId, String Name, String Label,
int MultipleArtists, int ArtistId) {
long result = -1;

try {


ContentValues initialValues = new ContentValues();
initialValues.put(KEY_ID, AlbumId);
initialValues.put(KEY_NAME, Name);
initialValues.put(KEY_LABEL, Label);
initialValues.put(KEY_ARTIST_ID, ArtistId);
initialValues.put(KEY_MULTIPLE_ARTISTS, MultipleArtists);

 result = db.insert(DATABASE_TABLE, null, initialValues);


} catch (Exception e) {
Log.i(Exception in addAlbumDB,  + e.toString());
return false;
}

if (result == -1)
return false;
return true;
}

The above function is called for around 2000 times..
Similarly there are 2 3 more functions for other tables.
Thanks,
Alok.

On Mon, Apr 12, 2010 at 2:33 PM, Michael Rueger mike.rue...@gmail.comwrote:

 On 4/12/2010 10:59 AM, Yahel wrote:

 Hi Alok,

 Posting some logic, or some sql would help us see if you are missing
 something :)


 (excessive) use of indices comes to mind :-)

 Michael



 Yahel

 On 12 avr, 08:50, Alok Kulkarnikulsu...@gmail.com  wrote:

 Hi,
 I am inserting around 7000 to 8000 records in my database having 4 tables
 each having 3 to 4 columns.Its taking me around 22 seconds to do the
 insertion which is i think is too long. I am using transaction while
 doing
 this without which its taking around 55 seconds.
 According to SQLite documentation , inserting 1 records in a database
 takes time  around 2 to 3 seconds.
 Am i missing something , or is the behaviour correct?
 Thanks,
 Alok



 --
 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.comandroid-developers%2bunsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en

 To unsubscribe, reply using remove me as the subject.


-- 
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

Re: [android-developers] Re: Database insertion timings

2010-04-12 Thread Alok Kulkarni
I have started the transaction before the 1st insert , and ended it after
the last insert
Thanks,
Alok.

On Mon, Apr 12, 2010 at 4:01 PM, Alok Kulkarni kulsu...@gmail.com wrote:

 Ok,
 @Yahel:- For the insertion of same records on a Palm device(Say Palm Pre) ,
 its taking 3 seconds..
 On an IPhone , its taking 1 or  2 seconds..
 Here is an example of what i am doing..
 private Boolean addAlbumDB(int AlbumId, String Name, String Label,
 int MultipleArtists, int ArtistId) {
 long result = -1;

 try {


 ContentValues initialValues = new ContentValues();
 initialValues.put(KEY_ID, AlbumId);
 initialValues.put(KEY_NAME, Name);
 initialValues.put(KEY_LABEL, Label);
 initialValues.put(KEY_ARTIST_ID, ArtistId);
 initialValues.put(KEY_MULTIPLE_ARTISTS, MultipleArtists);

  result = db.insert(DATABASE_TABLE, null, initialValues);


 } catch (Exception e) {
 Log.i(Exception in addAlbumDB,  + e.toString());
 return false;
 }

 if (result == -1)
 return false;
 return true;
 }

 The above function is called for around 2000 times..
 Similarly there are 2 3 more functions for other tables.
 Thanks,
 Alok.


 On Mon, Apr 12, 2010 at 2:33 PM, Michael Rueger mike.rue...@gmail.comwrote:

 On 4/12/2010 10:59 AM, Yahel wrote:

 Hi Alok,

 Posting some logic, or some sql would help us see if you are missing
 something :)


 (excessive) use of indices comes to mind :-)

 Michael



 Yahel

 On 12 avr, 08:50, Alok Kulkarnikulsu...@gmail.com  wrote:

 Hi,
 I am inserting around 7000 to 8000 records in my database having 4
 tables
 each having 3 to 4 columns.Its taking me around 22 seconds to do the
 insertion which is i think is too long. I am using transaction while
 doing
 this without which its taking around 55 seconds.
 According to SQLite documentation , inserting 1 records in a
 database
 takes time  around 2 to 3 seconds.
 Am i missing something , or is the behaviour correct?
 Thanks,
 Alok



 --
 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.comandroid-developers%2bunsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en

 To unsubscribe, reply using remove me as the subject.




-- 
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: Database insertion timings

2010-04-12 Thread MobDev
do you have some code specifically showing the sequence and the
syntax ?
AAfaik a transaction SHOULD make it faster accroding to this
documentation : 
http://web.utk.edu/~jplyon/sqlite/SQLite_optimization_FAQ.html#transactions

On 12 apr, 12:32, Alok Kulkarni kulsu...@gmail.com wrote:
 I have started the transaction before the 1st insert , and ended it after
 the last insert
 Thanks,
 Alok.

 On Mon, Apr 12, 2010 at 4:01 PM, Alok Kulkarni kulsu...@gmail.com wrote:
  Ok,
  @Yahel:- For the insertion of same records on a Palm device(Say Palm Pre) ,
  its taking 3 seconds..
  On an IPhone , its taking 1 or  2 seconds..
  Here is an example of what i am doing..
  private Boolean addAlbumDB(int AlbumId, String Name, String Label,
              int MultipleArtists, int ArtistId) {
          long result = -1;

          try {

              ContentValues initialValues = new ContentValues();
              initialValues.put(KEY_ID, AlbumId);
              initialValues.put(KEY_NAME, Name);
              initialValues.put(KEY_LABEL, Label);
              initialValues.put(KEY_ARTIST_ID, ArtistId);
              initialValues.put(KEY_MULTIPLE_ARTISTS, MultipleArtists);

               result = db.insert(DATABASE_TABLE, null, initialValues);

          } catch (Exception e) {
              Log.i(Exception in addAlbumDB,  + e.toString());
              return false;
          }

          if (result == -1)
              return false;
          return true;
      }

  The above function is called for around 2000 times..
  Similarly there are 2 3 more functions for other tables.
  Thanks,
  Alok.

  On Mon, Apr 12, 2010 at 2:33 PM, Michael Rueger 
  mike.rue...@gmail.comwrote:

  On 4/12/2010 10:59 AM, Yahel wrote:

  Hi Alok,

  Posting some logic, or some sql would help us see if you are missing
  something :)

  (excessive) use of indices comes to mind :-)

  Michael

  Yahel

  On 12 avr, 08:50, Alok Kulkarnikulsu...@gmail.com  wrote:

  Hi,
  I am inserting around 7000 to 8000 records in my database having 4
  tables
  each having 3 to 4 columns.Its taking me around 22 seconds to do the
  insertion which is i think is too long. I am using transaction while
  doing
  this without which its taking around 55 seconds.
  According to SQLite documentation , inserting 1 records in a
  database
  takes time  around 2 to 3 seconds.
  Am i missing something , or is the behaviour correct?
  Thanks,
  Alok

  --
  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.comandroid-developers%2bunsubscr...@googlegroups.com
  For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en

  To unsubscribe, reply using remove me as the subject.

-- 
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


Re: [android-developers] Re: Database insertion timings

2010-04-12 Thread Alok Kulkarni
This is a standard class DatabaseHelper extending SQLiteOpenHelper...


private static class DatabaseHelper extends SQLiteOpenHelper {
DatabaseHelper(Context context, String databaseName) {
super(context, databaseName, null, DATABASE_VERSION);
}

@Override
public void onCreate(SQLiteDatabase db) {
// Nothing to do
}

@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int
newVersion) {
Log
.w(Upgrade, Upgrading database from version 
+ oldVersion +  to  + newVersion
+ , which will destroy all old data);
db.execSQL(DROP TABLE IF EXISTS titles);
onCreate(db);
}
}

Then i have
private SQLiteDatabase db;
This db object is used to perform insert operations.
Thanks,
Alok.
// ---opens the database---

public void open() throws SQLException {
db = DBHelper.getWritableDatabase();
}

On Mon, Apr 12, 2010 at 6:20 PM, MobDev developm...@mobilaria.com wrote:

 do you have some code specifically showing the sequence and the
 syntax ?
 AAfaik a transaction SHOULD make it faster accroding to this
 documentation :
 http://web.utk.edu/~jplyon/sqlite/SQLite_optimization_FAQ.html#transactionshttp://web.utk.edu/%7Ejplyon/sqlite/SQLite_optimization_FAQ.html#transactions

 On 12 apr, 12:32, Alok Kulkarni kulsu...@gmail.com wrote:
  I have started the transaction before the 1st insert , and ended it after
  the last insert
  Thanks,
  Alok.
 
  On Mon, Apr 12, 2010 at 4:01 PM, Alok Kulkarni kulsu...@gmail.com
 wrote:
   Ok,
   @Yahel:- For the insertion of same records on a Palm device(Say Palm
 Pre) ,
   its taking 3 seconds..
   On an IPhone , its taking 1 or  2 seconds..
   Here is an example of what i am doing..
   private Boolean addAlbumDB(int AlbumId, String Name, String Label,
   int MultipleArtists, int ArtistId) {
   long result = -1;
 
   try {
 
   ContentValues initialValues = new ContentValues();
   initialValues.put(KEY_ID, AlbumId);
   initialValues.put(KEY_NAME, Name);
   initialValues.put(KEY_LABEL, Label);
   initialValues.put(KEY_ARTIST_ID, ArtistId);
   initialValues.put(KEY_MULTIPLE_ARTISTS, MultipleArtists);
 
result = db.insert(DATABASE_TABLE, null, initialValues);
 
   } catch (Exception e) {
   Log.i(Exception in addAlbumDB,  + e.toString());
   return false;
   }
 
   if (result == -1)
   return false;
   return true;
   }
 
   The above function is called for around 2000 times..
   Similarly there are 2 3 more functions for other tables.
   Thanks,
   Alok.
 
   On Mon, Apr 12, 2010 at 2:33 PM, Michael Rueger mike.rue...@gmail.com
 wrote:
 
   On 4/12/2010 10:59 AM, Yahel wrote:
 
   Hi Alok,
 
   Posting some logic, or some sql would help us see if you are missing
   something :)
 
   (excessive) use of indices comes to mind :-)
 
   Michael
 
   Yahel
 
   On 12 avr, 08:50, Alok Kulkarnikulsu...@gmail.com  wrote:
 
   Hi,
   I am inserting around 7000 to 8000 records in my database having 4
   tables
   each having 3 to 4 columns.Its taking me around 22 seconds to do the
   insertion which is i think is too long. I am using transaction while
   doing
   this without which its taking around 55 seconds.
   According to SQLite documentation , inserting 1 records in a
   database
   takes time  around 2 to 3 seconds.
   Am i missing something , or is the behaviour correct?
   Thanks,
   Alok
 
   --
   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.comandroid-developers%2bunsubscr...@googlegroups.com
 android-developers%2bunsubscr...@googlegroups.comandroid-developers%252bunsubscr...@googlegroups.com
 
   For more options, visit this group at
  http://groups.google.com/group/android-developers?hl=en
 
   To unsubscribe, reply using remove me as the subject.

 --
 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.comandroid-developers%2bunsubscr...@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 

[android-developers] Re: Database insertion timings

2010-04-12 Thread MobDev
I don't see a specific transaction ???
Anyways transaction should only be used if you have multiple actions
you are doing on your database (like several insert/update
operations)...

On 12 apr, 15:43, Alok Kulkarni kulsu...@gmail.com wrote:
 This is a standard class DatabaseHelper extending SQLiteOpenHelper...

 private static class DatabaseHelper extends SQLiteOpenHelper {
         DatabaseHelper(Context context, String databaseName) {
             super(context, databaseName, null, DATABASE_VERSION);
         }

         @Override
         public void onCreate(SQLiteDatabase db) {
             // Nothing to do
         }

         @Override
         public void onUpgrade(SQLiteDatabase db, int oldVersion, int
 newVersion) {
             Log
                     .w(Upgrade, Upgrading database from version 
                             + oldVersion +  to  + newVersion
                             + , which will destroy all old data);
             db.execSQL(DROP TABLE IF EXISTS titles);
             onCreate(db);
         }
     }

 Then i have
 private SQLiteDatabase db;
 This db object is used to perform insert operations.
 Thanks,
 Alok.
     // ---opens the database---

     public void open() throws SQLException {
         db = DBHelper.getWritableDatabase();
     }

 On Mon, Apr 12, 2010 at 6:20 PM, MobDev developm...@mobilaria.com wrote:
  do you have some code specifically showing the sequence and the
  syntax ?
  AAfaik a transaction SHOULD make it faster accroding to this
  documentation :
 http://web.utk.edu/~jplyon/sqlite/SQLite_optimization_FAQ.html#transa...http://web.utk.edu/%7Ejplyon/sqlite/SQLite_optimization_FAQ.html#tran...

  On 12 apr, 12:32, Alok Kulkarni kulsu...@gmail.com wrote:
   I have started the transaction before the 1st insert , and ended it after
   the last insert
   Thanks,
   Alok.

   On Mon, Apr 12, 2010 at 4:01 PM, Alok Kulkarni kulsu...@gmail.com
  wrote:
Ok,
@Yahel:- For the insertion of same records on a Palm device(Say Palm
  Pre) ,
its taking 3 seconds..
On an IPhone , its taking 1 or  2 seconds..
Here is an example of what i am doing..
private Boolean addAlbumDB(int AlbumId, String Name, String Label,
            int MultipleArtists, int ArtistId) {
        long result = -1;

        try {

            ContentValues initialValues = new ContentValues();
            initialValues.put(KEY_ID, AlbumId);
            initialValues.put(KEY_NAME, Name);
            initialValues.put(KEY_LABEL, Label);
            initialValues.put(KEY_ARTIST_ID, ArtistId);
            initialValues.put(KEY_MULTIPLE_ARTISTS, MultipleArtists);

             result = db.insert(DATABASE_TABLE, null, initialValues);

        } catch (Exception e) {
            Log.i(Exception in addAlbumDB,  + e.toString());
            return false;
        }

        if (result == -1)
            return false;
        return true;
    }

The above function is called for around 2000 times..
Similarly there are 2 3 more functions for other tables.
Thanks,
Alok.

On Mon, Apr 12, 2010 at 2:33 PM, Michael Rueger mike.rue...@gmail.com
  wrote:

On 4/12/2010 10:59 AM, Yahel wrote:

Hi Alok,

Posting some logic, or some sql would help us see if you are missing
something :)

(excessive) use of indices comes to mind :-)

Michael

Yahel

On 12 avr, 08:50, Alok Kulkarnikulsu...@gmail.com  wrote:

Hi,
I am inserting around 7000 to 8000 records in my database having 4
tables
each having 3 to 4 columns.Its taking me around 22 seconds to do the
insertion which is i think is too long. I am using transaction while
doing
this without which its taking around 55 seconds.
According to SQLite documentation , inserting 1 records in a
database
takes time  around 2 to 3 seconds.
Am i missing something , or is the behaviour correct?
Thanks,
Alok

--
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.comandroid-developers%2bunsubscr...@googlegroups.com
  android-developers%2bunsubscr...@googlegroups.comandroid-developers%252bunsubscr...@googlegroups.com

For more options, visit this group at
   http://groups.google.com/group/android-developers?hl=en

To unsubscribe, reply using remove me as the subject.

  --
  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.comandroid-developers%2bunsubscr...@googlegroups.com
  For more options, visit this group at
 

Re: [android-developers] Re: Database insertion timings

2010-04-12 Thread Alok Kulkarni
Before the 1st insert call i am doing
db.beginTransaction();

for(i = 0 i 2000 ; i++)
   addAlbumDB();
for(i = 0 i 3000 ; i++)
   addArtistDB();
for(i = 0 i 2000 ; i++)
   addSongDB();
try {
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}


On Mon, Apr 12, 2010 at 7:18 PM, MobDev developm...@mobilaria.com wrote:

 I don't see a specific transaction ???
 Anyways transaction should only be used if you have multiple actions
 you are doing on your database (like several insert/update
 operations)...

 On 12 apr, 15:43, Alok Kulkarni kulsu...@gmail.com wrote:
  This is a standard class DatabaseHelper extending SQLiteOpenHelper...
 
  private static class DatabaseHelper extends SQLiteOpenHelper {
  DatabaseHelper(Context context, String databaseName) {
  super(context, databaseName, null, DATABASE_VERSION);
  }
 
  @Override
  public void onCreate(SQLiteDatabase db) {
  // Nothing to do
  }
 
  @Override
  public void onUpgrade(SQLiteDatabase db, int oldVersion, int
  newVersion) {
  Log
  .w(Upgrade, Upgrading database from version 
  + oldVersion +  to  + newVersion
  + , which will destroy all old data);
  db.execSQL(DROP TABLE IF EXISTS titles);
  onCreate(db);
  }
  }
 
  Then i have
  private SQLiteDatabase db;
  This db object is used to perform insert operations.
  Thanks,
  Alok.
  // ---opens the database---
 
  public void open() throws SQLException {
  db = DBHelper.getWritableDatabase();
  }
 
  On Mon, Apr 12, 2010 at 6:20 PM, MobDev developm...@mobilaria.com
 wrote:
   do you have some code specifically showing the sequence and the
   syntax ?
   AAfaik a transaction SHOULD make it faster accroding to this
   documentation :
  http://web.utk.edu/~jplyon/sqlite/SQLite_optimization_FAQ.html#transa..http://web.utk.edu/%7Ejplyon/sqlite/SQLite_optimization_FAQ.html#transa..
 .http://web.utk.edu/%7Ejplyon/sqlite/SQLite_optimization_FAQ.html#tran..
 .
 
   On 12 apr, 12:32, Alok Kulkarni kulsu...@gmail.com wrote:
I have started the transaction before the 1st insert , and ended it
 after
the last insert
Thanks,
Alok.
 
On Mon, Apr 12, 2010 at 4:01 PM, Alok Kulkarni kulsu...@gmail.com
   wrote:
 Ok,
 @Yahel:- For the insertion of same records on a Palm device(Say
 Palm
   Pre) ,
 its taking 3 seconds..
 On an IPhone , its taking 1 or  2 seconds..
 Here is an example of what i am doing..
 private Boolean addAlbumDB(int AlbumId, String Name, String Label,
 int MultipleArtists, int ArtistId) {
 long result = -1;
 
 try {
 
 ContentValues initialValues = new ContentValues();
 initialValues.put(KEY_ID, AlbumId);
 initialValues.put(KEY_NAME, Name);
 initialValues.put(KEY_LABEL, Label);
 initialValues.put(KEY_ARTIST_ID, ArtistId);
 initialValues.put(KEY_MULTIPLE_ARTISTS,
 MultipleArtists);
 
  result = db.insert(DATABASE_TABLE, null,
 initialValues);
 
 } catch (Exception e) {
 Log.i(Exception in addAlbumDB,  + e.toString());
 return false;
 }
 
 if (result == -1)
 return false;
 return true;
 }
 
 The above function is called for around 2000 times..
 Similarly there are 2 3 more functions for other tables.
 Thanks,
 Alok.
 
 On Mon, Apr 12, 2010 at 2:33 PM, Michael Rueger 
 mike.rue...@gmail.com
   wrote:
 
 On 4/12/2010 10:59 AM, Yahel wrote:
 
 Hi Alok,
 
 Posting some logic, or some sql would help us see if you are
 missing
 something :)
 
 (excessive) use of indices comes to mind :-)
 
 Michael
 
 Yahel
 
 On 12 avr, 08:50, Alok Kulkarnikulsu...@gmail.com  wrote:
 
 Hi,
 I am inserting around 7000 to 8000 records in my database having
 4
 tables
 each having 3 to 4 columns.Its taking me around 22 seconds to do
 the
 insertion which is i think is too long. I am using transaction
 while
 doing
 this without which its taking around 55 seconds.
 According to SQLite documentation , inserting 1 records in a
 database
 takes time  around 2 to 3 seconds.
 Am i missing something , or is the behaviour correct?
 Thanks,
 Alok
 
 --
 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.comandroid-developers%2bunsubscr...@googlegroups.com
 

Re: [android-developers] Re: Database insertion timings

2010-04-12 Thread Alok Kulkarni
Each of these above functions insert records in 3 seperate tables in the
same database.
Thanks ,
Alok

On Mon, Apr 12, 2010 at 7:51 PM, Alok Kulkarni kulsu...@gmail.com wrote:

 Before the 1st insert call i am doing
 db.beginTransaction();

 for(i = 0 i 2000 ; i++)
addAlbumDB();
 for(i = 0 i 3000 ; i++)
addArtistDB();
 for(i = 0 i 2000 ; i++)
addSongDB();
 try {
 db.setTransactionSuccessful();
 } finally {
 db.endTransaction();

 }


 On Mon, Apr 12, 2010 at 7:18 PM, MobDev developm...@mobilaria.com wrote:

 I don't see a specific transaction ???
 Anyways transaction should only be used if you have multiple actions
 you are doing on your database (like several insert/update
 operations)...

 On 12 apr, 15:43, Alok Kulkarni kulsu...@gmail.com wrote:
  This is a standard class DatabaseHelper extending SQLiteOpenHelper...
 
  private static class DatabaseHelper extends SQLiteOpenHelper {
  DatabaseHelper(Context context, String databaseName) {
  super(context, databaseName, null, DATABASE_VERSION);
  }
 
  @Override
  public void onCreate(SQLiteDatabase db) {
  // Nothing to do
  }
 
  @Override
  public void onUpgrade(SQLiteDatabase db, int oldVersion, int
  newVersion) {
  Log
  .w(Upgrade, Upgrading database from version 
  + oldVersion +  to  + newVersion
  + , which will destroy all old data);
  db.execSQL(DROP TABLE IF EXISTS titles);
  onCreate(db);
  }
  }
 
  Then i have
  private SQLiteDatabase db;
  This db object is used to perform insert operations.
  Thanks,
  Alok.
  // ---opens the database---
 
  public void open() throws SQLException {
  db = DBHelper.getWritableDatabase();
  }
 
  On Mon, Apr 12, 2010 at 6:20 PM, MobDev developm...@mobilaria.com
 wrote:
   do you have some code specifically showing the sequence and the
   syntax ?
   AAfaik a transaction SHOULD make it faster accroding to this
   documentation :
  
 http://web.utk.edu/~jplyon/sqlite/SQLite_optimization_FAQ.html#transa..http://web.utk.edu/%7Ejplyon/sqlite/SQLite_optimization_FAQ.html#transa..
 .http://web.utk.edu/%7Ejplyon/sqlite/SQLite_optimization_FAQ.html#tran..
 .
 
   On 12 apr, 12:32, Alok Kulkarni kulsu...@gmail.com wrote:
I have started the transaction before the 1st insert , and ended it
 after
the last insert
Thanks,
Alok.
 
On Mon, Apr 12, 2010 at 4:01 PM, Alok Kulkarni kulsu...@gmail.com
   wrote:
 Ok,
 @Yahel:- For the insertion of same records on a Palm device(Say
 Palm
   Pre) ,
 its taking 3 seconds..
 On an IPhone , its taking 1 or  2 seconds..
 Here is an example of what i am doing..
 private Boolean addAlbumDB(int AlbumId, String Name, String Label,
 int MultipleArtists, int ArtistId) {
 long result = -1;
 
 try {
 
 ContentValues initialValues = new ContentValues();
 initialValues.put(KEY_ID, AlbumId);
 initialValues.put(KEY_NAME, Name);
 initialValues.put(KEY_LABEL, Label);
 initialValues.put(KEY_ARTIST_ID, ArtistId);
 initialValues.put(KEY_MULTIPLE_ARTISTS,
 MultipleArtists);
 
  result = db.insert(DATABASE_TABLE, null,
 initialValues);
 
 } catch (Exception e) {
 Log.i(Exception in addAlbumDB,  + e.toString());
 return false;
 }
 
 if (result == -1)
 return false;
 return true;
 }
 
 The above function is called for around 2000 times..
 Similarly there are 2 3 more functions for other tables.
 Thanks,
 Alok.
 
 On Mon, Apr 12, 2010 at 2:33 PM, Michael Rueger 
 mike.rue...@gmail.com
   wrote:
 
 On 4/12/2010 10:59 AM, Yahel wrote:
 
 Hi Alok,
 
 Posting some logic, or some sql would help us see if you are
 missing
 something :)
 
 (excessive) use of indices comes to mind :-)
 
 Michael
 
 Yahel
 
 On 12 avr, 08:50, Alok Kulkarnikulsu...@gmail.com  wrote:
 
 Hi,
 I am inserting around 7000 to 8000 records in my database
 having 4
 tables
 each having 3 to 4 columns.Its taking me around 22 seconds to
 do the
 insertion which is i think is too long. I am using transaction
 while
 doing
 this without which its taking around 55 seconds.
 According to SQLite documentation , inserting 1 records in
 a
 database
 takes time  around 2 to 3 seconds.
 Am i missing something , or is the behaviour correct?
 Thanks,
 Alok
 
 --
 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 

[android-developers] Re: Database insertion timings

2010-04-12 Thread MobDev
Actually, Im just guessing here, shouldnt you use staretTransaction
and endTransaction instead of setTransactionSuccesfull() ???
Right now you as a developer are specifically marking the transaction
as succesfull, is that what you want ?

On 12 apr, 16:22, Alok Kulkarni kulsu...@gmail.com wrote:
 Each of these above functions insert records in 3 seperate tables in the
 same database.
 Thanks ,
 Alok

 On Mon, Apr 12, 2010 at 7:51 PM, Alok Kulkarni kulsu...@gmail.com wrote:
  Before the 1st insert call i am doing
  db.beginTransaction();

  for(i = 0 i 2000 ; i++)
     addAlbumDB();
  for(i = 0 i 3000 ; i++)
     addArtistDB();
  for(i = 0 i 2000 ; i++)
     addSongDB();
  try {
              db.setTransactionSuccessful();
          } finally {
              db.endTransaction();

          }

  On Mon, Apr 12, 2010 at 7:18 PM, MobDev developm...@mobilaria.com wrote:

  I don't see a specific transaction ???
  Anyways transaction should only be used if you have multiple actions
  you are doing on your database (like several insert/update
  operations)...

  On 12 apr, 15:43, Alok Kulkarni kulsu...@gmail.com wrote:
   This is a standard class DatabaseHelper extending SQLiteOpenHelper...

   private static class DatabaseHelper extends SQLiteOpenHelper {
           DatabaseHelper(Context context, String databaseName) {
               super(context, databaseName, null, DATABASE_VERSION);
           }

           @Override
           public void onCreate(SQLiteDatabase db) {
               // Nothing to do
           }

           @Override
           public void onUpgrade(SQLiteDatabase db, int oldVersion, int
   newVersion) {
               Log
                       .w(Upgrade, Upgrading database from version 
                               + oldVersion +  to  + newVersion
                               + , which will destroy all old data);
               db.execSQL(DROP TABLE IF EXISTS titles);
               onCreate(db);
           }
       }

   Then i have
   private SQLiteDatabase db;
   This db object is used to perform insert operations.
   Thanks,
   Alok.
       // ---opens the database---

       public void open() throws SQLException {
           db = DBHelper.getWritableDatabase();
       }

   On Mon, Apr 12, 2010 at 6:20 PM, MobDev developm...@mobilaria.com
  wrote:
do you have some code specifically showing the sequence and the
syntax ?
AAfaik a transaction SHOULD make it faster accroding to this
documentation :

 http://web.utk.edu/~jplyon/sqlite/SQLite_optimization_FAQ.html#transa..http://web.utk.edu/%7Ejplyon/sqlite/SQLite_optimization_FAQ.html#transa..
  .http://web.utk.edu/%7Ejplyon/sqlite/SQLite_optimization_FAQ.html#tran..
  .

On 12 apr, 12:32, Alok Kulkarni kulsu...@gmail.com wrote:
 I have started the transaction before the 1st insert , and ended it
  after
 the last insert
 Thanks,
 Alok.

 On Mon, Apr 12, 2010 at 4:01 PM, Alok Kulkarni kulsu...@gmail.com
wrote:
  Ok,
  @Yahel:- For the insertion of same records on a Palm device(Say
  Palm
Pre) ,
  its taking 3 seconds..
  On an IPhone , its taking 1 or  2 seconds..
  Here is an example of what i am doing..
  private Boolean addAlbumDB(int AlbumId, String Name, String Label,
              int MultipleArtists, int ArtistId) {
          long result = -1;

          try {

              ContentValues initialValues = new ContentValues();
              initialValues.put(KEY_ID, AlbumId);
              initialValues.put(KEY_NAME, Name);
              initialValues.put(KEY_LABEL, Label);
              initialValues.put(KEY_ARTIST_ID, ArtistId);
              initialValues.put(KEY_MULTIPLE_ARTISTS,
  MultipleArtists);

               result = db.insert(DATABASE_TABLE, null,
  initialValues);

          } catch (Exception e) {
              Log.i(Exception in addAlbumDB,  + e.toString());
              return false;
          }

          if (result == -1)
              return false;
          return true;
      }

  The above function is called for around 2000 times..
  Similarly there are 2 3 more functions for other tables.
  Thanks,
  Alok.

  On Mon, Apr 12, 2010 at 2:33 PM, Michael Rueger 
  mike.rue...@gmail.com
wrote:

  On 4/12/2010 10:59 AM, Yahel wrote:

  Hi Alok,

  Posting some logic, or some sql would help us see if you are
  missing
  something :)

  (excessive) use of indices comes to mind :-)

  Michael

  Yahel

  On 12 avr, 08:50, Alok Kulkarnikulsu...@gmail.com  wrote:

  Hi,
  I am inserting around 7000 to 8000 records in my database
  having 4
  tables
  each having 3 to 4 columns.Its taking me around 22 seconds to
  do the
  insertion which is i think is too long. I am using transaction
  while
  doing
  this without which its taking around 55 seconds.
  According to SQLite 

[android-developers] Re: Database insertion timings

2010-04-12 Thread Yahel
Ok, you are right if the pre and the iphone are 10x faster, it can't
be right.

I don't see anything wrong in your code, so only two things come to
mind :

- Instead of using ContentValues, try to create an insert sql
statement and send it to via SQLiteDatabase.execSQL to see if there is
any improvement
- Maybe it's not the database writing that is slow but the reading
from wherever your getting the data ?

Yahel


On 12 avr, 12:31, Alok Kulkarni kulsu...@gmail.com wrote:
 Ok,
 @Yahel:- For the insertion of same records on a Palm device(Say Palm Pre) ,
 its taking 3 seconds..
 On an IPhone , its taking 1 or  2 seconds..
 Here is an example of what i am doing..
 private Boolean addAlbumDB(int AlbumId, String Name, String Label,
             int MultipleArtists, int ArtistId) {
         long result = -1;

         try {

             ContentValues initialValues = new ContentValues();
             initialValues.put(KEY_ID, AlbumId);
             initialValues.put(KEY_NAME, Name);
             initialValues.put(KEY_LABEL, Label);
             initialValues.put(KEY_ARTIST_ID, ArtistId);
             initialValues.put(KEY_MULTIPLE_ARTISTS, MultipleArtists);

              result = db.insert(DATABASE_TABLE, null, initialValues);

         } catch (Exception e) {
             Log.i(Exception in addAlbumDB,  + e.toString());
             return false;
         }

         if (result == -1)
             return false;
         return true;
     }

 The above function is called for around 2000 times..
 Similarly there are 2 3 more functions for other tables.
 Thanks,
 Alok.

 On Mon, Apr 12, 2010 at 2:33 PM, Michael Rueger mike.rue...@gmail.comwrote:



  On 4/12/2010 10:59 AM, Yahel wrote:

  Hi Alok,

  Posting some logic, or some sql would help us see if you are missing
  something :)

  (excessive) use of indices comes to mind :-)

  Michael

  Yahel

  On 12 avr, 08:50, Alok Kulkarnikulsu...@gmail.com  wrote:

  Hi,
  I am inserting around 7000 to 8000 records in my database having 4 tables
  each having 3 to 4 columns.Its taking me around 22 seconds to do the
  insertion which is i think is too long. I am using transaction while
  doing
  this without which its taking around 55 seconds.
  According to SQLite documentation , inserting 1 records in a database
  takes time  around 2 to 3 seconds.
  Am i missing something , or is the behaviour correct?
  Thanks,
  Alok

  --
  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.comandroid-developers%2Bunsubs 
  cr...@googlegroups.com
  For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en

  To unsubscribe, reply using remove me as the subject.

-- 
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: Database insertion timings

2010-04-12 Thread Zsolt Vasvari
No, database writing is extremely slow especially with many indecies.

In my app, I am getting maybe 10 insers a seconds into a table with 20
columns and 15 indecies.  As my app is probably 99.9% reads, I didn't
try optimizing the writes too much, not sure if it's even possible.

On Apr 13, 12:33 am, Yahel kaye...@gmail.com wrote:
 Ok, you are right if the pre and the iphone are 10x faster, it can't
 be right.

 I don't see anything wrong in your code, so only two things come to
 mind :

 - Instead of using ContentValues, try to create an insert sql
 statement and send it to via SQLiteDatabase.execSQL to see if there is
 any improvement
 - Maybe it's not the database writing that is slow but the reading
 from wherever your getting the data ?

 Yahel

 On 12 avr, 12:31, Alok Kulkarni kulsu...@gmail.com wrote:



  Ok,
  @Yahel:- For the insertion of same records on a Palm device(Say Palm Pre) ,
  its taking 3 seconds..
  On an IPhone , its taking 1 or  2 seconds..
  Here is an example of what i am doing..
  private Boolean addAlbumDB(int AlbumId, String Name, String Label,
              int MultipleArtists, int ArtistId) {
          long result = -1;

          try {

              ContentValues initialValues = new ContentValues();
              initialValues.put(KEY_ID, AlbumId);
              initialValues.put(KEY_NAME, Name);
              initialValues.put(KEY_LABEL, Label);
              initialValues.put(KEY_ARTIST_ID, ArtistId);
              initialValues.put(KEY_MULTIPLE_ARTISTS, MultipleArtists);

               result = db.insert(DATABASE_TABLE, null, initialValues);

          } catch (Exception e) {
              Log.i(Exception in addAlbumDB,  + e.toString());
              return false;
          }

          if (result == -1)
              return false;
          return true;
      }

  The above function is called for around 2000 times..
  Similarly there are 2 3 more functions for other tables.
  Thanks,
  Alok.

  On Mon, Apr 12, 2010 at 2:33 PM, Michael Rueger 
  mike.rue...@gmail.comwrote:

   On 4/12/2010 10:59 AM, Yahel wrote:

   Hi Alok,

   Posting some logic, or some sql would help us see if you are missing
   something :)

   (excessive) use of indices comes to mind :-)

   Michael

   Yahel

   On 12 avr, 08:50, Alok Kulkarnikulsu...@gmail.com  wrote:

   Hi,
   I am inserting around 7000 to 8000 records in my database having 4 
   tables
   each having 3 to 4 columns.Its taking me around 22 seconds to do the
   insertion which is i think is too long. I am using transaction while
   doing
   this without which its taking around 55 seconds.
   According to SQLite documentation , inserting 1 records in a 
   database
   takes time  around 2 to 3 seconds.
   Am i missing something , or is the behaviour correct?
   Thanks,
   Alok

   --
   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.comandroid-developers%2Bunsubs
cr...@googlegroups.com
   For more options, visit this group at
  http://groups.google.com/group/android-developers?hl=en

   To unsubscribe, reply using remove me as the subject.- Hide quoted text 
   -

 - Show quoted text -

-- 
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: Database : XML or SQLite ?

2010-03-30 Thread ko5tik

JSON is also  an option:

http://github.com/ko5tik/jsonserializer


( unless you like to write  SAX / DOM  yourself, you will need kind of
data binding)

regards,

-- 
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

To unsubscribe from this group, send email to 
android-developers+unsubscribegooglegroups.com or reply to this email with the 
words REMOVE ME as the subject.


[android-developers] Re: Database : XML or SQLite ?

2010-03-29 Thread Kumar Bibek
Yes you can do this. You can put your xml file in the assets
directory. When you app is launched, read this file, and do whatever
you want.

Note: You cannot delete this file from the assets directory from
within the app. It will be there forever.

Thanks and Regards,
Kumar Bibek

On Mar 25, 1:03 pm, Emmanuel Dafflon lol482...@gmail.com wrote:
 Hello,

 I'm doing a application that will use a database with serialized
 object.
 The objects will be already serialized and the user will just display
 things.
 On a PC I would just make an XML but with android I'm not sure.
 Can I make an XML and unpack it when the user launch the application
 for the first time or should I do something else?

 Best regards,

 rXp!

-- 
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

To unsubscribe from this group, send email to 
android-developers+unsubscribegooglegroups.com or reply to this email with the 
words REMOVE ME as the subject.


[android-developers] Re: Database management

2010-02-27 Thread Paul
Thanks for the good advice.
To make the database accessible in other Activities I initialize again
in each Activity, which seems to work, but I get log messages that say
I need to close the database. If I close the database when leaving an
activity, then it isn't available in onActivityResult when it returns,
so I have to initialize again.
It seems like I am initializing and closing way too much and it is
obvious I don't know what I am doing!
When you stay the database stays around forever until the process is
killed, is there a simpler way to do multiple activities? Do I need to
close the database when the process is killed or does Android do it?

On Feb 27, 1:27 am, Dianne Hackborn hack...@android.com wrote:
 I would recommend having a static singleton objects that is used to access
 the database -- it creates the database when it is first retrieved as part
 of its initialization, allows clients to get the database and/or provides
 convenience APIs for interacting with the database, and simply stays around
 forever (until the process is killed).





 On Fri, Feb 26, 2010 at 10:07 PM, Paul paul@gmail.com wrote:
  What is the best approach to managing a small SQLite database private
  to the application?
  Open (getWritableDatabase) in OnStart and close in OnStop in each
  Activity?
  Open in OnCreate and keep open til the user quits the app (where would
  you put close?)
  Open, do work and close as soon as possible each time it is needed?

  --
  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.comandroid-developers%2Bunsubs 
  cr...@googlegroups.com
  For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en

 --
 Dianne Hackborn
 Android framework engineer
 hack...@android.com

 Note: please don't send private questions to me, as I don't have time to
 provide private support, and so won't reply to such e-mails.  All such
 questions should be posted on public forums, where I and others can see and
 answer them.

-- 
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: Database management

2010-02-26 Thread James Wang
My suggestion is create your own content provider for this and open db
in onCreate and hold it as static.

-- 
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: database update

2010-02-25 Thread Dan
thanks, so the onCreate gets called when the database has not been
created and the onupgrade gets called when the database has been
created, but the app is being upgraded?  Do these methods get called
due to some global variable that gets reset upon a fresh or upgraded
install of the app?

On Feb 25, 9:44 am, Mark Murphy mmur...@commonsware.com wrote:
 Dan wrote:
  I've got a question about updating an app after release.  If I have a
  database that contains 10 columns and I add a feature that requires an
  11th column after the app has been released, where would I put the sql
  code to add the new column so that when they install the app it keeps
  their current data, but adds that 11th column?

 In onUpgrade() of your SQLiteOpenHelper subclass.

 --
 Mark Murphy (a Commons 
 Guy)http://commonsware.com|http://twitter.com/commonsguy

 Warescription: Three Android Books, Plus Updates, One Low Price!

-- 
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


Re: [android-developers] Re: database update

2010-02-25 Thread Mark Murphy
Dan wrote:
 thanks, so the onCreate gets called when the database has not been
 created and the onupgrade gets called when the database has been
 created, but the app is being upgraded? 

Yes on the first. More accurately for the second, onUpgrade() will be
called when the schema revision (parameter in the SQLiteOpenHelper
constructor) changes.

 Do these methods get called
 due to some global variable that gets reset upon a fresh or upgraded
 install of the app?

No, they get called when you ask your SQLiteOpenHelper subclass to
getWriteableDatabase(), for example. The determination of whether an
upgrade is needed is based on some metadata tucked away in some corner
of the database.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy

Warescription: Three Android Books, Plus Updates, One Low Price!

-- 
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: database question

2009-10-23 Thread Wouter

Can someone help me?

On Oct 20, 5:36 pm, Wouter wouterg...@gmail.com wrote:
 Hey,

 I am working on a project for a belgium Tv Guide.
 Now I download a database (.db) file from a server to the sdcard to
 work with.
 In this database are 2 tabels, tvchannels and tvprograms.
 Now I can do several updates to the tvchannels table and i want to
 make a backup of this table to a lokal database file. How can i do
 that? I want to do this because I have to download a  new database
 file every daye from the server and the channels that are choses are
 saved in the tvchannels database. I want to backup this database table
 and when the new database file (tvgids.db) is downloaded I want to
 replace the tvchannels database (from downloaded database file) with
 the backup from tvchannels..

 Anyone has an idea?

 Thank you,

 Wouter
--~--~-~--~~~---~--~~
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: database question

2009-10-23 Thread Mark Murphy

Wouter wrote:
 Now I can do several updates to the tvchannels table and i want to
 make a backup of this table to a lokal database file. How can i do
 that?

Copy the database file to a backup file. Either you already know your
path to your database, or you can use getDatabasePath() to find that path.

To be safe, I recommend you have all SQLite* objects and Cursors on that
database closed before making the file copy.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy

Android 1.6 Programming Books: http://commonsware.com/books

--~--~-~--~~~---~--~~
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: database question

2009-10-23 Thread Wouter

Hey Mark,

Thanks for the answer. So how can i backup that database file? I now
have a file tvgids.db on my sdcard (so path is /sdcard/tvgids.db)

How can I make a copy of that?

Wouter

On 23 okt, 19:05, Mark Murphy mmur...@commonsware.com wrote:
 Wouter wrote:
  Now I can do several updates to the tvchannels table and i want to
  make a backup of this table to a lokal database file. How can i do
  that?

 Copy the database file to a backup file. Either you already know your
 path to your database, or you can use getDatabasePath() to find that path.

 To be safe, I recommend you have all SQLite* objects and Cursors on that
 database closed before making the file copy.

 --
 Mark Murphy (a Commons 
 Guy)http://commonsware.com|http://twitter.com/commonsguy

 Android 1.6 Programming Books:http://commonsware.com/books
--~--~-~--~~~---~--~~
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: database question

2009-10-23 Thread Mark Murphy

Wouter wrote:
 Hey Mark,
 
 Thanks for the answer. So how can i backup that database file? I now
 have a file tvgids.db on my sdcard (so path is /sdcard/tvgids.db)
 
 How can I make a copy of that?

Java file I/O.

http://exampledepot.com/egs/java.io/CopyFile.html

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy

Android 1.6 Programming Books: http://commonsware.com/books

--~--~-~--~~~---~--~~
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: database question

2009-10-23 Thread Wouter

Nice thank you so much Mark!

On Oct 23, 7:56 pm, Mark Murphy mmur...@commonsware.com wrote:
 Wouter wrote:
  Hey Mark,

  Thanks for the answer. So how can i backup that database file? I now
  have a file tvgids.db on my sdcard (so path is /sdcard/tvgids.db)

  How can I make a copy of that?

 Java file I/O.

 http://exampledepot.com/egs/java.io/CopyFile.html

 --
 Mark Murphy (a Commons 
 Guy)http://commonsware.com|http://twitter.com/commonsguy

 Android 1.6 Programming Books:http://commonsware.com/books
--~--~-~--~~~---~--~~
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: Database for an online application

2009-08-27 Thread Zod

Hi!

I was developing an application quite similar to yours. Although I had
to freeze the project because I'm becoming a father in the coming
weeks, and it sure messed up my project schedules :)

I had a site up and running with php and on top of that with the zend
framework, which received and responded in simple xml format to
queries and updates too. A request looked something like this
request authcode= command=locationlocation lat=xx.xx
long=xx.xx accuracy=xx time=x/tagSome text/tag/
request

It was easy to parse on the server side, and it was stored in a mysql
database.

I've chosen XML based communication through http because beside the
android application I've been implementing a web based ajax
application which could have been used by anyone even without an
android phone.

Bye,
   Zsolt

On Aug 27, 4:31 am, Vijay vijay.meenakshisunda...@gmail.com wrote:
 Hello all,
              I'm creating a map application on Android in which users
 share info. among them. i'e., one user's marking on the map should be
 available to other users. What might be the best design for such type
 of communication?(like where can i host my database, file exchange
 format etc)

 Thanks.
--~--~-~--~~~---~--~~
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: Database problems...

2009-07-30 Thread Jack Ha
I don't see that you have CREATE_TABLE_COMPUTERS defined.

--
Jack Ha
Open Source Development Center
・T・ ・ ・Mobile・ stick together

The views, opinions and statements in this email are those of
the author solely in their individual capacity, and do not
necessarily represent those of T-Mobile USA, Inc.


On Jul 30, 8:47 am, Skeniver skeni...@gmail.com wrote:
 Hi there

 I am trying to create a database with two tables. Employees and
 Computers. A spinner with employee names fill properly when I don't
 try create and do anything with the second table... The code to create
 is:

 private static class DBOpenHelper extends SQLiteOpenHelper {
                 private static final String CREATE_TABLE_USERS = create 
 table  +
                                 TABLE_USERS +  ( + USER_KEY_ID +
                                  integer primary key autoincrement,  +
                                 USER_KEY_USER +  text not null,  +
                                 USER_KEY_PIN +  string);;
                 private static final String CREATE_TABLE_ACCOUNTS = create 
 table 
 +
                                 TABLE_COMPUTERS +  ( + ACC_KEY_ID +
                                  integer primary key autoincrement,  +
                                 ACC_KEY_USERID +  integer not null,  +
                                 ACC_KEY_COMP_SERIAL +  text not null);;

                 public DBOpenHelper(Context context, String name,
                                 CursorFactory factory, int version) {
                         super(context, name, factory, version);
                 }

                 @Override
                 public void onCreate(SQLiteDatabase _db) {
                         _db.execSQL(CREATE_TABLE_USERS);
                         _db.execSQL(CREATE_TABLE_COMPUTERS);
                 }

 Is there somehting I am doing wrong during the creating, as the rest
 of the code (to read data) is exactly the same... but I can't figure
 it out.

 Please help!!!

 Thanks in advance,
 Neil
--~--~-~--~~~---~--~~
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: Database Pattern - What's your method?

2009-06-02 Thread hina naz
* **visit my site and earn more money**  *

*  http://latesttechnologyinfo.com/*

* ** http://latesttechnologyinfo.com/*

*  **http://latesttechnologyinfo.com/*

* ** http://latesttechnologyinfo.com/*

*  **http://latesttechnologyinfo.com/*

*  **http://latesttechnologyinfo.com/**  *

* http://latesttechnologyinfo.com/*

--~--~-~--~~~---~--~~
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: Database Pattern - What's your method?

2009-06-02 Thread Numan Ahmed
--- On wed, 6/3/09, numan numan@gmail.com wrote:

hello my friend how are u
latest summer fashion hot fashion videos
visit my website http://www.fashioninfokit.com/

--~--~-~--~~~---~--~~
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: Database issue on device

2009-06-01 Thread Sam

hi,
 I am using G1 not the DEV phone does it matter ...

On Jun 2, 10:04 am, Sam csgo...@gmail.com wrote:
 hi,
            i am using a db file and trying to access that file thru
 emulator it works perfectly fine but when i run the same app on device
 i get the error of no such table when i checked the path also it gives
 the right path and also the status of database open flag it returns
 true not able to guess what i am i doing wrong i have changed the
 permissions of database folder also for the emulator still no luck for
 that reason i wanted to check the folder of device are the db files
 present ... Thnx in advance...
--~--~-~--~~~---~--~~
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: database table design problem

2009-05-25 Thread Saurav Mukherjee
the only fast sol that i can think of is to group the types together n store
in another table...
like 1,2 as A
1,2,3 as B
etc...
then refer rge table for usage!

On Fri, May 22, 2009 at 11:14 AM, quill quill...@163.com wrote:


 Hi guys,
 I have a column which describes note type, the value of the type may
 be 1, 2, 3.(some int numbers). The problem is that the type value
 may be one of those numbers, or some of the numbers, such as the type
 may belong to1 and also belong to 2..
 When I create the table, I may create it like this:
 CREATE TABLE  + NOTES_TABLE_NAME +  (
+ Notes._ID +  INTEGER PRIMARY KEY,
+ Notes.TYPE +  TEXT
+ ););
 I set TEXT to Notes.TYPE, so it can save the type '1 and 2' like
 this 1,2, But when I query the item whose Notes.TYPE is 1, you
 know, type 1,2 also satisfys this, And I should do some string
 spliting in order to query this.
 Is there any easy way to solve this?
 Thanks!
 


--~--~-~--~~~---~--~~
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: database sqlite doubt

2009-05-25 Thread Mark Murphy

Saurav Mukherjee wrote:
 db = dbHelper.getWritableDatabase();
 table = db.rawQuery(select * from PROJECTS, null);
 boolean f = false;
 taskList = new ArrayListString();
 while (table.moveToNext()) {
 if (table.getString(1).equals(selectedProject)) {
 f = true;
 taskList.add(table.getString(3));
 
 
 
 this is a part of my code...
 point is i ve created the tables properly n wen i print the column count
 n row count, its all updated...
 also durin insert (not shown), i ve checked the return, n it returns the
 rowid!!!
 there is an exception at the line: if
 (table.getString(1).equals(selectedProject)) {  in the above code...
 
 any ideas that might help me to remove the exception???

You could look at the stack trace, via adb logcat or DDMS, to see what
the exception is. For example, if it is a NullPointerException, then
probably table.getString(1) is returning NULL.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy

Android Development Wiki: http://wiki.andmob.org

--~--~-~--~~~---~--~~
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: database table design problem

2009-05-22 Thread stonestrange stone
There is something wrong with your database designing.
And you need to add a table storing note type.

2009/5/22 Jason Proctor ja...@particularplace.com


 you basically have a one (note) to many (note type) relationship.

 model this with two tables --

 create table notes (id integer primary key);

 create table note_types (note_id integer references notes, type integer);

 to add a type to a note, insert into note_types. to find out whether
 a note is of a particular type, or to get all the types for a
 particular note, select from note_types.



 Hi guys,
 I have a column which describes note type, the value of the type may
 be 1, 2, 3.(some int numbers). The problem is that the type value
 may be one of those numbers, or some of the numbers, such as the type
 may belong to1 and also belong to 2..
 When I create the table, I may create it like this:
 CREATE TABLE  + NOTES_TABLE_NAME +  (
  + Notes._ID +  INTEGER PRIMARY KEY,
  + Notes.TYPE +  TEXT
  + ););
 I set TEXT to Notes.TYPE, so it can save the type '1 and 2' like
 this 1,2, But when I query the item whose Notes.TYPE is 1, you
 know, type 1,2 also satisfys this, And I should do some string
 spliting in order to query this.
 Is there any easy way to solve this?
 Thanks!
 

 --
 jason.software.particle

 


--~--~-~--~~~---~--~~
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: database table design problem

2009-05-22 Thread quill

oh Thank you, Jason! I get it!
Thank you all guys!

On May 22, 1:57 pm, Jason Proctor ja...@particularplace.com wrote:
 you basically have a one (note) to many (note type) relationship.

 model this with two tables --

 create table notes (id integer primary key);

 create table note_types (note_id integer references notes, type integer);

 to add a type to a note, insert into note_types. to find out whether
 a note is of a particular type, or to get all the types for a
 particular note, select from note_types.





 Hi guys,
 I have a column which describes note type, the value of the type may
 be 1, 2, 3.(some int numbers). The problem is that the type value
 may be one of those numbers, or some of the numbers, such as the type
 may belong to1 and also belong to 2..
 When I create the table, I may create it like this:
 CREATE TABLE  + NOTES_TABLE_NAME +  (
                      + Notes._ID +  INTEGER PRIMARY KEY,
                      + Notes.TYPE +  TEXT
                      + ););
 I set TEXT to Notes.TYPE, so it can save the type '1 and 2' like
 this 1,2, But when I query the item whose Notes.TYPE is 1, you
 know, type 1,2 also satisfys this, And I should do some string
 spliting in order to query this.
 Is there any easy way to solve this?
 Thanks!

 --
 jason.software.particle- Hide quoted text -

 - Show quoted text -
--~--~-~--~~~---~--~~
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: database table design problem

2009-05-21 Thread Jason Proctor

you basically have a one (note) to many (note type) relationship.

model this with two tables --

create table notes (id integer primary key);

create table note_types (note_id integer references notes, type integer);

to add a type to a note, insert into note_types. to find out whether 
a note is of a particular type, or to get all the types for a 
particular note, select from note_types.



Hi guys,
I have a column which describes note type, the value of the type may
be 1, 2, 3.(some int numbers). The problem is that the type value
may be one of those numbers, or some of the numbers, such as the type
may belong to1 and also belong to 2..
When I create the table, I may create it like this:
CREATE TABLE  + NOTES_TABLE_NAME +  (
 + Notes._ID +  INTEGER PRIMARY KEY,
 + Notes.TYPE +  TEXT
 + ););
I set TEXT to Notes.TYPE, so it can save the type '1 and 2' like
this 1,2, But when I query the item whose Notes.TYPE is 1, you
know, type 1,2 also satisfys this, And I should do some string
spliting in order to query this.
Is there any easy way to solve this?
Thanks!


-- 
jason.software.particle

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



  1   2   >