Question SQL-Lite

Hello, I was wondering if it would be the right way to implement a database SQL-LITE and if I had to submit my application code runs correctly?

URI myURI = URI.create("file:///SDCard/flash.db");
d = DatabaseFactory.create(myURI);
d.close();

I want to save a database to the SD card and was hoping that this was accomplished over there without any other necessary implementation.  For example whenever I have rn that on the Simulator, I need to create a directory for this database.  What it will be just as easy as this presentation and the database is stored on the sd card?

Thank you

Scientist

Yes, this create a file named flash.db in the SD card, but outside the records.

To save the file in the folder document from SD card, you can use

"file:///SDCard/Blackberry/documents"+fileName;

Hope this helps.

------------------------------------------------------------------------------------
Kudo press to say thank you to the developer.
Also, press accept it as a button when you got the Solution.

Tags: BlackBerry Developers

Similar Questions

  • WebWorks and persistent or storage SQL Lite

    Hello

    I'm looking for more help write webworks app for persistent storage or SQL lite storage,

    Anyone can throw some light on this.

    Thank you.

    Hi tububerry,
    You can see https://developer.blackberry.com/html5/apis/Database.html
    https://developer.BlackBerry.com/HTML5/APIs/localStorage.html

    and here's the example source code: http://blog.darkcrimson.com/samples/localdb/darkcrimson_localdb_demo.zip

    A Pham

  • Sql-Lite problem

    I looked at the documentation and many examples, but I can't seem to get my departure from the database sql - lite.

    I created the database in the screen here:

    URI myURI = URI.create("file:///SDCard/flash.sqlite");
    
    d = DatabaseFactory.create(myURI);
    
    d.close();
    

    I tried to register information in the database here:

    URI myURI = URI.create("file:///SDCard/flash.sqlite");
     DatabaseFactory.open(myURI);
    
     Statement st = d.createStatement( "CREATE TABLE 'Restaurant' (  'Experience' TEXT,  )" );
    
     d.createStatement("INSERT INTO Restaurant(Experience) " +
     "VALUES ('message1')");
    
     st.prepare();
     st.execute();
     st.close();
     d.close();
    
     Dialog.alert("Your info was saved!");
    

    Any ideas what im doing wrong?

    Thank you

    Scientist

    It should work

    BCZ I work on dat only.

    You need to do sumthing wrong;

    Just check your code.

    Debug your code you find error wl.

    Try like dat.

    URI myURI = URI.create("file:///SDCard/database/flash.db");
    
  • SQL LITE

    Hello everyone, I'm wanting to create a sql database lite for my application to store and retrieve data.  I know very little on the subject and I was wondering if someone can point me in the direction of some great examples or documentation?

    Thank you

    Scientist

    Hello

    SQL Lite is easy for the Blackberry.

    Here I am attaching some of the classes may b that will help you.

    public URI myURI;
    myURI = URI.create("file:///SDCard/BlackBerry/Database/"
                        + "DatabaseName.db");
                this.setMyURI(myURI);
        public URI getMyURI() {
            return myURI;
        }
    
        public void setMyURI(URI myURI) {
            this.myURI = myURI;
        }
    
    //Now generate one class which is having all database table fields
    //if you are using 3 tables den u have to make 3 classes
    
    Example
    
    public class Schema {
        Database db;
    
        public Schema() {
                URI newURI = UiApplication.getUiApplication().getMyURI();
                db = DatabaseFactory.open(newURI);
                Statement user= db.createStatement("CREATE TABLE 'User' ( "
                        + "'ID' INTEGER PRIMARY KEY AUTOINCREMENT," + "'Name' Text," + "'Password' Text," + "'Email' Text)");
                user.prepare();
                user.execute();
                user.close();
    //2nd schema
        ......
                db.close();
    
        }
    
    }
    

    In your main class where you want to insert/change/remove data write these codes

    Database dbLink;
    URI newURI = UiApplication.getUiApplication().getMyURI();
    dbLink = DatabaseFactory.create(newURI);
    dbLink.close();
    Schema s = new Schema();
    db = DatabaseFactory.open(newURI);
    String Username = "BB";
    String Password = "BlackBerry";
    String Email = "";
    
        Statement st = db.createStatement("INSERT INTO User(Name,Password,Email)"
                    + " VALUES ('"
                    + Username
                    + "','"
                    + Password + "','" + Email + "')");
        st.prepare();
        st.execute();
    
        db.close();
    

    ----------------------------------------------------------
    feel free to press the congratulations on the left side to thank the user who has helped you.
    Please mark as resolved messages if you found a solution.

  • Issue of database SQL-lite

    If I created a sql database - lite in my application and the database is created when the application starts, how I would write a condition statement to not recognize the creation of database code?

    Is there a better way to do what I'm trying to do here I saw more?

    Here's my code for creation of data base that I want to only be invoked if the database is not present and must be created:

                      try
            {
                URI myURI = URI.create("file:///SDCard/flash.db");
                d = DatabaseFactory.create(myURI);
                d.close();
            }
            catch(Exception e)
            {
    
            }
    
            try
            {
                URI myURI = URI.create("/SDCard/flash.db");
                d = DatabaseFactory.open(myURI);
                Statement st = d.createStatement("CREATE TABLE 'Restaurant' (  'Experience' TEXT, 'Date' TEXT)");
                st.prepare();
                st.execute();
                st.close();
                d.close();
            }
            catch(Exception e)
            {
    
            }
    

    You must use FileConnection, look at this code example.

            url="file:///SDCard/Databases/flash.db";
            if(f==ok)
            {
                try
                {
                    FileConnection fc=(FileConnection)Connector.open(url, Connector.READ_WRITE);
                    if(!fc.exists())
                    {
                        URI uri=URI.create("file:///SDCard/Databases/flash.db");
                        d=DatabaseFactory.create(uri);
                    }
                    else
                    {
                        Dialog.alert("File Exits! Proceed");
                    }
                    d.close();
                }catch(Exception e)
                {
                    System.out.println(e.getMessage());
                    e.printStackTrace();
                }
       }
    

    ------------------------------------------------------------------------------------
    Kudo press to say thank you to the developer.
    Also, press accept it as a button when you got the Solution.

  • SQL-Lite create Table?

    I am wanting to save a string of text in a sql database - lite which is called "message1."  I press save button to call this code in my interlocutor.

    URI myURI = URI.create("file:///SDCard/flash.db");
    DatabaseFactory.open(myURI);
    Statement st = d.createStatement( "CREATE TABLE Restaurant (Experience TEXT)" );
    Dialog.alert("Here1!");
    st.prepare();
    st.execute();
    st.close();  
    
    Statement st1 = d.createStatement("INSERT INTO Restaurant(Experience) VALUES ('message1')");
    st1.prepare();
    st1.execute();
    st1.close();
    d.close();
    Dialog.alert("Your info was saved!");
    

    I can't even my Dialog statement to appear?  I do something wrong in the line where I create the table?

    Statement st = d.createStatement ('CREATE TABLE Restaurant (experience TEXT)');

    Because when I move the dialog statement before this line... I can see the dialog box

    Database db;
    URI myURI = URI.create("file:///SDCard/flash.db");
    db = DatabaseFactory.open(myURI);
    
    Statement st= db.createStatement("CREATE TABLE 'Restaurant' ( "
                        + "'Experience' TEXT)");
                st.prepare();
                st.execute();
                st.close();
    
                Statement st1 = db.createStatement("INSERT INTO Restaurant(Experience) VALUES ('Message1')");
                st1.prepare();
                st1.execute();
    
    db.close();
    

    I checked the code and its working very well.

    ----------------------------------------------------------
    feel free to press the congratulations on the left side to thank the user who has helped you.
    Please mark as resolved messages if you found a solution.

  • Newb question: SQL query on an imported table

    Hi all. I'm a newb, that this issue will probably tell you!
    But I am very interested to familiarize themselves with the Oracle environment.

    I installed 10g Express.
    I was able to set up a new user (schema) profile?

    I created a new table, by importing an Excel file, saved as a CSV file. It has a PK.

    When I log in as an administrator, I can see the table 'discovers' the content.
    However, I can't run a SQL command with the new table.
    It is said Table or view does not exist.

    The table is called "Customers" and contains a column called "City" and I type City Select From Customers.

    Like the Adminisistrator, I have "given" all the rights for the new table to my profile newly created (schema).
    When I connect as long as this new person, I can't see the new table imported into the list of tables, yet alone to run an application or a SQL to it. What did I miss?

    Any tips will be appreciated. Glyn gray...

    Published by: user12501005 on February 7, 2010 11:26

    Hello

    You wrote:
    The original table is still visible to the diagram of the system, but he reports yet again as saying that the table does not exist when I try SQL.
    So is there a reason why a table imported is visible to the user DBA, but SQL does not exist?
    The other imported tables, those the DBA can run SQL still aren't visible to other users (schemas).
    The DBA has "tuned" EVERYTHING to the default HR schema.
    When I connect like HR, I'm unable to find the given table and SQL reports that the table does not exist.

    If I understand that you have created a Table in the schema of the SYSTEM, and you cannot question him by SQL.

    For example, if you then create a table A in the diagram of SYSTEM, you can view the table A if you connect to the database
    SYSTEM or any intended user he has the privilege to CHOOSE ANY TABLE.

    If you are connected to a user (for example, HR), which does not have this privilege, you can not query the Table.

    If you have a privilege to HR as follows:

    connect system/
    grant select on A to HR;
    

    Then you can query the Table has to HR:

    connect HR/
    select * from system.A;
    

    Hope this helps.
    Best regards
    Jean Valentine

  • newbie question: sql runs under sqlplus but does not compile in pl/sql?

    I have the following two tables, I have a SQL in pl/sql packages so I can use dbms_jobs to automate it however, I get the compile time error. It seems to me that pl/sql dislikes my sql that works well in sqlplus. Here is the error message and my test case?

    mdb_user@cmd > view the error
    PACKAGE BODY DATA_QUALITY_REPORT_P errors:

    LINE/COL ERROR
    -------- -----------------------------------------------------------------
    10/1 PL/SQL: statement ignored
    13/42 PL/SQL: ORA-00942: table or view does not exist





    create the table S_ORG_EXT
    (
    accnt_type_cd varchar2 (100),
    cust_stat_cd varchar2 (100)
    )
    /

    insert into s_org_ext
    Select column_name, data_type for user_tab_columns where rownum < = 100
    /

    Select * from s_org_ext
    /


    create the table data_quality_report
    (
    RunId number not null,
    report_type number of non-null, - type of report as dup dup or not other measures
    org_level number not null, - organization level nsgn, sgn, shipto
    loc_level number of non-null, - local level by city, by country, by region, grand_total
    name varchar2 (100) not null,-the line output of the tot name.
    Value number not null, - line value of the tot.
    rundate date default sysdate
    )
    /

    create sequence data_quality_report_seq with 1000
    INCREMENT BY 1
    NOCACHE
    NOCYCLE
    /


    insert into data_quality_report
    Select data_quality_report_seq.nextval, 3, 99, 99, accnt_type_cd, cnt, sysdate from
    (
    Select accnt_type_cd, count cnt (*) of S_ORG_EXT where cust_stat_cd = 'VARCHAR2' group by accnt_type_cd by 2 desc order
    )
    /

    Select * from data_quality_report
    /



    truncate table data_quality_report

    CREATE or replace PACKAGE data_quality_report_p AS
    function pull_data return data_quality_report.runid%type;
    END data_quality_report_p;
    /


    create or replace package body data_quality_report_p as
    function pull_data return data_quality_report.runid%type is

    new_rid data_quality_report.runid%type;


    Start
    Select data_quality_report_seq.nextval in the double new_rid;

    insert into data_quality_report
    Select new_rid, 3, 999999, 999999, accnt_type_cd, cnt, sysdate from
    (
    Select accnt_type_cd, count cnt (*) of S_ORG_EXT where cust_stat_cd = 'VARCHAR2' group by accnt_type_cd by 2 desc order
    );


    Return new_rid;
    exception
    When no_data_found then
    DBMS_OUTPUT. Put_line ("NO_DATA_FOUND handles the exception.");
    while others then
    DBMS_OUTPUT. Put_line ("' handling ANOTHER exception.");


    end; -end pull_data

    end data_quality_report_p;
    /

    Hello

    Sorry, I was not clear about that.
    The owner of the package needs direct privileges (not only privileges through a role) to compile the code, whehter it is DEFINE AUTHID or AUTHID CURRENT_USER. Option (3) does not help in this case; my mistake.

    I usually create packages in the same schema tables they use, which was option (2) in my previous message. There may be good reasons why you can't do that; for example, the package may reference multiple schemas tables. In this case, grant the necessary privileges directly to the owner of the whole.

  • Quick question - SQL + constraint dashboard

    Hello

    I have 3 dashboard invites you: exercise, Qtr, and month and here is my requirement...

    -All 3 dashboard guests must display only values for the past 5 years, including the current year
    -Quarter and months guests should be limited

    Now the problem is, I could achieve the requirement of the 1st or the 2nd but I am unable to make the two together since OBIEE does not show the box 'Force' if we select 'Results' rather than 'all values '. Is there a way to achieve both requirements together?

    I did a lot of searching on Google, but that did not help. So thought I'd check with the experts in this forum.

    Thank you
    Vahib

    You have three columns to the prompt year, quarter, and month, no need sql result...

    In the special effects of the year column write this
    Case when TableA.Year enters the year (current_date)-5 and year (current_date) then TableA.Year end

    Column quarter FX
    When end of TableA.Year between the year (current_date) - 5 and year (current_date) then TableA.Quarter

    special effects of the column for the month
    When end of TableA.Year between the year (current_date) - 5 and year (current_date) then TableA.Month

    Select the constraint for the quarter and month

    Thank you
    Vino

  • The question SQL generated by the motion of the Hyperion Intelligence report

    I have 2 tables and I'm pulling the column 'PRSN_NO' first table (A) and the "POOL_NM" of second column table (B).

    The join between A and B are

    A Left Outer Join B on A.PTY_ID = B.PTY_ID
    AND B.Start_dt < = A.End_dt
    AND B.Start_dt > = A.Start_dt

    The query exported the form

    SELECT DISTINCT AL1. PRSN_NO, AL2. POOL_NM
    OF VADIM_IR. AN AL1
    LEFT OUTER JOIN VADIM_IR. B AL2
    ON (AL1. PTY_ID = AL2. PTY_ID)
    WHERE
    (AL2. Start_dt < = AL1. End_dt
    AND AL2. Start_dt > = AL1. Start_dt)


    My expectation is

    SELECT DISTINCT AL1. PRSN_NO, AL2. POOL_NM
    OF VADIM_IR. AN AL1
    LEFT OUTER JOIN VADIM_IR. B AL2
    ON (AL1. PTY_ID = AL2. PTY_ID)
    AND (AL2. Start_dt < = AL1. End_dt
    AND AL2. Start_dt > = AL1. Start_dt)


    Please help me on this. I hope there is a setting in the creation of the eco file to get the outer join condition in the filter and I have not checked but still I am getting the join condition in the filter.

    Thank you
    KP

    have you try to define/set of this part of the sql ("(AL2.)") Start_dt<=>
    AND AL2. Start_dt > = AL1. Start_dt)"as a sql custom Start_dt fileld limiit?

  • Please, I want someone to answer this questions SQL?

    1. display the name, the month and the year of accession of all employees, stored on the months of their date of hiring and in that on the year, with the first year that appears first?

    Can be.

    You can explain further.

    Cordially salim

    SQL> select ename,to_char(hiredate,'mm-yyyy') month_year from emp order by hiredate;
    
    ENAME      MONTH_Y
    ---------- -------
    SMITH      12-1980
    ALLEN      02-1981
    WARD       02-1981
    JONES      04-1981
    BLAKE      05-1981
    CLARK      06-1981
    TURNER     09-1981
    MARTIN     09-1981
    KING       11-1981
    JAMES      12-1981
    FORD       12-1981
    MILLER     01-1982
    SCOTT      04-1987
    ADAMS      05-1987
    
    14 rows selected.
    
    SQL> 
    
  • SQL Lite: Cannot write into the error of database readonly on release on appworld sandbox

    Hello

    everything was workin find in development mode, but when I downloaded and run my app from appworld sandbox I get the following error:

    SQLLite:

    "Cannot write to readonly database error"

    Thanks in advance...

    It is a database in your application / folder (i.e. comes your file .bar automatically during the installation)?

    You should not write in the app / folder in your application. This can be done in development mode, but it is intended only as a convenience for certain types of deployment of debugging (if you do not have to copy all the files on each time you make a change).

    If you have data in your application, what needs to be changed after the installation, it must be copied into the app. / data folder when the application first runs (or, at least, when it must first change).

    Information here: https://developer.blackberry.com/native/documentation/bb10/com.qnx.doc.native_sdk.devguide/com.qnx.d...

  • Report, SQL query based on the values of the elements (question SQL)

    Hello

    I use APEX 4.0 with Oracle 10 g r2 under Windows XP Pro SP3.

    I have an interactive report and a menu with a few items to filter the report.

    It works with most of the elements, but my problem is to select lists that have additional values, for example:
    SELECT '(null)' display_value, 'NULL' return_value FROM DUAL
    UNION ALL
    select distinct(SPAT_AREA_NAME) display_value, SPAT_AREA_NAME return_value 
    from SPATIAL_POINTS
    order by 1
    and I will return null as ' (return '%').

    For example, if the user selects "(null)", the report should return all rows with a NULL value in the column AREA_NAME.
    If he chooses "", the report should return all the lines. "
    and if the user selects a value, the report should return all the lines containing the value in column AREA_NAME.

    I don't know how to build my application. I tried with the CASE statements, DECODE, etc... but I still can't!

    My report query is for now:
    select SPAT_ID,
     SPAT_ACCL_NAME,
     SPAT_AREA_NAME,
     SPAT_CLASS,
     SPAT_NUMBER,
     SPAT_PT,
     SPAT_TYPE,
     SPAT_STATUS,
    from SPATIAL_POINTS 
    where 
     upper(SPAT_AREA_NAME) LIKE upper(:P3_FILTRE_AREA_NAME)  AND
     upper(SPAT_ACCL_NAME) LIKE upper(:P3_FILTRE_ACC_NAME) AND
     upper(SPAT_CLASS) LIKE '%'||upper(:P3_SPATIAL_CLASS)||'%' AND
     instr(upper(:P3_SPATIAL_TYPE_VALUES),upper(SPAT_TYPE)) > 0 AND
     instr(upper(:P3_SPATIAL_STATUS_VALUES),upper(SPAT_STATUS)) > 0 AND
     instr(upper(:P3_SPATIAL_POINT_VALUES),upper(SPAT_PT)) > 0
    Any idea?

    Thank you!

    Yann.

    Hello

    Then, assuming that spat_accl_name is not a string value "NULL" then you can try this...

    SELECT spat_id,
           spat_accl_name,
           spat_area_name,
           spat_class,
           spat_number,
           spat_pt,
           spat_type,
           spat_status,
           ROUND(spat_cumul,
                 (SELECT up_number_precision
                  FROM   user_preferences
                  WHERE  UPPER(up_nice_login) = UPPER(v('APP_USER'))))
              AS "SPAT_CUMUL"
    FROM   spatial_points
    WHERE  :p3_filtre_acc_name IS NULL AND spat_accl_name IS NULL
           OR(CASE
                 WHEN :p3_filtre_acc_name = '%' THEN NVL(spat_accl_name,'NULL')
                 ELSE :p3_filtre_acc_name
              END = NVL(spat_accl_name, 'NULL'))
    

    See you soon

    Ben

  • Question - SQL

    Hello
    I have the following line in a view:
    SUBSTR (DECODE (f.kind, 'F', FormatCpf (f.cic) FormatCgc (f.cnpj)), 1.18) the "CPF / CNPJ"
    But, the function returns the mask, even when the field is empty.
    When the field is empty, I want to return null, is not the result of the function. How?

    Thank you

    I'm sorry Ryu, there is something I don't understand.
    f.CIC and f.cnpj are numeric columns or not?

    In your previous post you wrote:

    When these fields are greater than zero, I want to return null and the masks...

    So I assumed that they where digital, but it seems that they are not numeric the error you get.

    If the only requirement is that, if f.cic and f.cnpj are null you want null otherwise you want the result of functions Format use the following syntax:

    SUBSTR (DECODE (f.TIPO, 'F', decode(f.cic,null,null,FormatCpf (f.cic)),decode(f.cnpj,null,null,FormatCgc (f.cnpj))), 1,18) as "CPF / CNPJ"
    

    Otherwise, provide the instructions CREATE TABLE and match the output of the sample.

    Max
    [My Italian blog Oracle | http://oracleitalia.wordpress.com/2010/01/02/query-gerarchiche/]

  • SNMP, generic SQL data loader, and built-in Port adapters

    Anyone have any success with using the SNMP (default MIB) and/or adapters third generic data SQL Loader?

    I'm under vCenter operations v5.7 VAPP and test the custom UI. I have installed the SNMP card, but when adding my own MIB they do not appear in the drop-down list when you try to add a new resource. I followed the docs to update the card with your own MIB files and everything is a - ok until I actually try to add a resource.

    I saw this KB:

    http://KB.VMware.com/selfservice/microsites/search.do?language=en_US & cmd = displayKC & externalId = 2034241

    But I loadded a few different mibs, poking around them in a mib browser, and each of them meet the requirements of that article.

    Regarding the SQL adapter. I add my instance of the adapter and the credentials and it tests fine, but when you add the resource to the environment overview screen, the 'Resource Type' dropdown is empty/non-editable. When I click ok, it of course gives me an error:

    The field 'type of Resrouce' is a required field. Please enter a value.

    Anyone who cross?

    Finally, there is documentation for the built-in Port Adapter? There is a very small excerpt in the card Guide:

    Reads a text that you set to determine the hosts and ports to monitor.

    But... where did you put this text?

    Two problems solved.

    First of all, the SNMP MIB has not picked up due to permissions on the file that I was transferred to the analytical VM. Duh. Evolution of the property of admin: admin corrects this problem. VMWare has taken this error.

    Also found a solution to the question SQL by clicking... the random button it appears that does not refresh the kind of resources until you run an auto-discovery. After crossing the Autodiscover queries, the drop-down list the type of resource is now available from the manual discovery. However, to make changes to the query/discovery files requires another automatic discovery for the changes to be picked up.

Maybe you are looking for