|
I have a project with Java Eclipse for android which stores data in SQLLite. My issue comes in when I include 100 lines of INSERT, it prompts me the EXCEEDED 65535 bytes.
Is it possible to place 2 "provider android:name=" in manifest then create 2 sets of the ContentProvider then make the second provider run like a continuation of the first set?
Hope you can help me. This is my first project with android. Thank you.
|
|
|
|
|
false approach.
Why do you insert 100 rows into the database at once? what is that? can't you narrow that down?
you should limit the data - paging could also be a solution.
|
|
|
|
|
What my objective is to update the database if there is a new version. Normally 1 category contains between 50 to 100 records which I hardcode in ContentProvider. Since I was getting the exceeded 65535 error, I had to split the insert to 2 classes however I am not sure how. Should I place 2 Provider android:name in Manifest? I am lost.
However, if there are any better options I am open to it since I am very new to Java Eclipse.
Thank you.
|
|
|
|
|
Given the following code:
private String name;
private List<String> years;
private List<String> studyChoices;
private void doCheck() {
if (!name.isEmpty() || name == null) {
}
for (String year : years) {
if (!year.isEmpty() || year == null) {
}
}
for (String studyChoice : studyChoices) {
if (!studyChoice.isEmpty() || studyChoice == null){
}
}
}
How do I condense this code into a more elegant and OO solution? Maybe put it all in one list and check for each item in that list?
I would like something like:
'If any of these parameters were not passed in or if they are empty, output an error message, else give the desired output'.
Basically I have to write a Servlet that gets form parameters from the request and checks if all parameters were provided. If they were, it is then supposed to write an output page.
Any ideas?
Thanks
|
|
|
|
|
First thing is that all your tests are the wrong way round (and logically wrong I suspect), you should check the variable is not null before using it as a reference to a method thus:
if (name == null || name.isEmpty()) {
if (name != null && !name.isEmpty()) {
I am not sure how you would condense the two loops any more as they appear to be independent of each other.
|
|
|
|
|
Is this entered from a GUI or is this object coming from some API?
For a GUI you can also use a GUI sided validation. You can e.g. use a KeyListener and validate the entered value right away.
For an API side validation I would suggest a Validation Layer which has to be passed before the data is used.
Your code - as Richard already stated - is a bit mixed up. Here is a valid suggestion:
private void doCheck() {
if (name != null && name != "") {
for (String year : years) {
if (year != null && year != "" ) {
try{
int i = Integer.parseInt(year);
}
catch(Exception oException){
}
}
}
for (String studyChoice : studyChoices) {
if (studyChoice!=null && studyChoice != ""){
}
}
}
else{ }
}
|
|
|
|
|
i am trying to design a simulation with java for my project title location-aware communication to achieve social inclusion and social responsibility which is a telecommunication project which conveys messages to subscribers that are mostly affected or benefited by the piece of information and shows boosters that are necessary to make this possible.
|
|
|
|
|
We believe you. What is the question?
Peter
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
Structure - it's all about structure.
No matter if face to face, while working or anywhere else.
Especially when writing some.
|
|
|
|
|
Simulation with Java
If you've never failed... You've never lived...
|
|
|
|
|
Is there a question in all that babble somewhere?
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Hello
Is there an article to open an excel file and write through jxl files.
Every time I try to write into excel file a new file is created instead of opening the old file.
Pritha
|
|
|
|
|
prithaa wrote: Is there an article to open an excel file Quite possibly, have you tried a Google search?
prithaa wrote: a new file is created instead of opening the old file. Without seeing your code I don't think we can guess what you may be doing wrong.
[edit]
This method[^] is probably what you are looking for.
[/edit]
|
|
|
|
|
thanks
but the above link is not opening
my problem was the following
InputStream inp = new FileInputStream("d:/Writefile.xls");
WorkbookSettings ws = new WorkbookSettings();
Workbook wb = Workbook.getWorkbook(inp, ws);
Sheet sheet = wb.getSheet(0);
Number number;
number = new Number(0, 0, 453.25, times);
((WritableSheet) sheet).addCell(number);
wb.close();
The above code doesnt add the cell to the given file just opens the file.I get DispatchUnCaughtException for the line
((WritableSheet) sheet).addCell(number);
Thanks for the reply
Pritha
|
|
|
|
|
|
thanks Richard
but a
WritableWorkbook creates a new workbook and has no method which opens a workbook
Pritha
|
|
|
|
|
This method[^] creates one. May I suggest you go through all the documentation to check which methods are required to create the objects you are trying to work with.
|
|
|
|
|
thanks for the article
but i cant still open a writableworkbook .i can write on a new
workbook
but cant write on an existing workbook
I didnt find any method doing that either in writableworkbook
regards
Pritha
|
|
|
|
|
|
prithaa wrote: thanks for the article
I did not provide one, I wonder what you have been looking at.
prithaa wrote: but i cant still open a writableworkbook
Did you follow my advice and read all the documentation in the link I gave you? It clearly shows how to create a writeable workbook from an existing file.
|
|
|
|
|
yes i did read the link u sent and looked at the
class writablework
but there is no method which opens an existing .xls file
Regards
Pritha
|
|
|
|
|
Sorry, previous link was not correct owing to HTML frame. However, I think this one[^] is the best you will get.
|
|
|
|
|
thanks for replying
Workbook workbook = Workbook.getWorkbook(new File("d:/Writefile.xls"));
WritableWorkbook copy = Workbook.createWorkbook(new File("d:/Writefile1.xls"), workbook);
copy.write();
WritableSheet sheet = copy.getSheet("Report2");
Number number;
number = new Number(0, 0, 453.25, times);
sheet.addCell(number);
copy.write();
copy.close();
I want to open an existing file and add a cell to an existing sheet. The above code opens the file but the cell editing doesnt happen.
Regards
pritha
|
|
|
|
|
Sorry, no idea why that's happening; I think you may need to re-check the documentation and work with your debugger.
|
|
|
|
|
Thankyou Richard for your help
|
|
|
|