Wrox Programmer Forums
|
BOOK: Beginning Android Application Development
This is the forum to discuss the Wrox book Beginning Android Application Development by Wei-Meng Lee; ISBN: 978-1-1180-1711-1
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Android Application Development section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 15th, 2012, 08:34 AM
Registered User
 
Join Date: Mar 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default database problem wont work on real device

I have created a database file called questiondb

I am reading in the file with the code below

I used the DBAdapter class for my database.

{alex.android.development/alex.android.development.Basic_database_questionsA ctivity}: android.database.CursorIndexOutOfBoundsException: Index 0 requested, with a size of 0

try {
String destPath = "/data/data/" + getPackageName() + "/databases/QuestionDB";
File f = new File(destPath);
if (!f.exists()) {
System.out.println("where is the database file");
CopyDB( getBaseContext().getAssets().open("questiondb"),
new FileOutputStream(destPath));
}
} catch (FileNotFoundException e) {
Log.e(TAG, "message", e);
} catch (IOException e) {
Log.e(TAG, "message", e);
}

public void CopyDB(InputStream inputStream, OutputStream outputStream)
throws IOException {
//---copy 1K bytes at a time---
byte[] buffer = new byte[1024];
int length;
while ((length = inputStream.read(buffer)) > 0) {
outputStream.write(buffer, 0, length);
}
inputStream.close();
outputStream.close();
}





Similar Threads
Thread Thread Starter Forum Replies Last Post
Adodc connections variable wont work, need help honam00000 VB How-To 1 December 10th, 2006 11:21 AM
Example will not work in the real world ElMorenito BOOK: Wrox's ASP.NET 2.0 Visual Web Developer 2005 Express Edition Starter ISBN: 978-0-7645-8807-5 2 October 12th, 2006 01:18 PM
code clinic - Why wont example asp code work? jardbf Classic ASP Basics 3 April 27th, 2006 06:22 PM
JetComp Wont Work .....HELP!! timmaher Access VBA 3 August 25th, 2005 01:38 AM
Query wont work unless I copy and past into new on Mitch Access 1 March 4th, 2005 02:22 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.