Welcome!

Welcome to the Official BlackBerry Support Community Forums. This is your resource to discuss support topics with your peers, and learn from each other. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

Reply
Contributor
baalzaboul
Posts: 19
Registered: ‎11-30-2011
My Carrier: alfa

How to create a database on the phone memory not sdCard ?

Hello everyone.

My question is simple.

I want to create a database, how can I do and created on the phone memory ?

 

I have tried this:

 

try{    
                                    URI  uri3 = URI.create(
                                        "file:///SDCard/Databases/database1.db");

 

but catch the following error:

 

Invalid path name. Path does not contains a proper root list. See FileSystemRegistry class for details.

 

 

 

And thank you for your help.

Please use plain text.
Contributor
aldrian
Posts: 43
Registered: ‎01-19-2011
My Carrier: T-Mobile Austria

Re: How to create a database on the phone memory not sdCard ?

private static Database getDB() {

		Database db = null;

		try {

			URI uri = URI
					.create("file:///store/.../MyDataBase.db");

			if (!DatabaseFactory.exists(uri)) {
				db = DatabaseFactory.create(uri);
				Statement st = db
						.createStatement("CREATE TABLE IF NOT EXISTS tablename"
								+ "('name1' INTEGER, 'name2' INTEGER, 'name3' INTEGER, 'name41' TEXT);");
				st.prepare();
				st.execute();
				st.close();

			} else {
				db = DatabaseFactory.open(uri);
			}

			return db;

		} catch (final Exception e) {
			UiApplication.getUiApplication().invokeLater(new Runnable() {
				public void run() {
					Dialog.alert(e.toString());
				}
			});

		}
		return db;
	}

 

________________
mappau Dev Team
blackberry@mappau.com twitter.com/#!/mappau facebook.com/mappau.at
Please use plain text.
Contributor
baalzaboul
Posts: 19
Registered: ‎11-30-2011
My Carrier: alfa

Re: How to create a database on the phone memory not sdCard ?

i tried your code with    .create("file:///store/MyDataBase.db");

 

but got the following error:

net.rim.device.api.database.DatabaseIOException: File System not ready

Please use plain text.
Trusted Contributor
NGeldenhuys
Posts: 176
Registered: ‎04-12-2012
My Carrier: vodacom

Re: How to create a database on the phone memory not sdCard ?

Hello there

 

Did you find a sollution on how to store the database on the phone memory?

 

Thank you

Please use plain text.