In the Android database programming, have you ever encountered, I want to from the specified location of the existing database to operate the problem. Before I tried a lot of methods did not succeed, and then found a solution to the method.
The following describes the meaning of this code, the first step to determine whether the specified path strength exists, does not exist on the creation of design material Daquan. The second step is to copy the database under Android resources to the specified path below. The third step is to open or create the database according to the specified path, and then get the object of manipulating the database, get the object of manipulating the database, and then we can make the table in the database increase and remove the operation.
1. [Code]android program reads a database that already exists in the project string databasefilename = Database_path + "/" + database_name; &NB Sp File dir = new file (database_path); if (!dir.exists ()) dir.mkdir (); if (! ( New File (DatabaseFileName)). Exists ()) { inputstream is = Context.getresources (). Openrawresource ( R.raw.jobexam); fileoutputstream fos = new FileOutputStream (databasefilename); byte[] buffer = new byte[8192];http://www.huiyi8.com/sheji/ int count = 0; while (c Ount = is.read (buffer)) > 0) { fos.write (buffer, 0, count); } &NBSP ; Fos.close (); is.close (); } db = Sqlitedatabase.openorcreatedatabase ( DatabaseFileName, NULL);