Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by Tanatosx3 · Dec 28, 2015 at 07:41 PM · c#androidarraycrashquiz

Quiz on Android crashes, array alternatives ?

Hello :)

I just working on my quiz game and its gonna be pretty large with hundrets of topics and questions, BUT as it has grown over 100+ questions split in 10 topics, it starts to crash on android when the array gets filled.

When i tested with 30 Questions / 3 Topics in the beginning everything was running smooth.

So i think this is maybe too big for a android phone :/, any ideas how to use them without crashing when reaching over 100 questions or what mobile friendly i could use instead of these 3 Arrays ?:

Quiz_text = new string[1, 25, 17, 6];
Quiz_answere_number = new int[1, 25, 17, 1];
Quiz_size_number = new int[1, 25, 17, 1];

the array means [Language, Topic, Questions, Answere]

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Tanatosx3 · Dec 29, 2015 at 04:08 AM 0
Share

Thinking about implementing Sqlite, do you guys think this is the right way ?

avatar image allenallenallen Tanatosx3 · Dec 29, 2015 at 04:08 AM 0
Share

Use comments and not answers when you don't have an answer!!! Converted to comment.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by callen · Dec 28, 2015 at 08:38 PM

It looks like you're using 4D arrays there, which might be causing you issues. Without knowing how much data you're actually using, though, I can't tell. The arrays you define above should work, but new string[10,100,1000,10000] will almost certainly crash.

Also these "square arrays" may be instantiating lots of empty spaces, for instance if not all topics have the same number of questions, or not all questions need 6 answers. If this is the case, you'll probably want to use arrays-of-arrays instead, defined like new string[10][][][]. Then you have to create each individual sub array, BUT they can be different sizes, like Quiz_text[0] = new string[10][][], and Quiz_text[1] = new string[8][][].

But doing that will get you into indexing nightmares, so I'd pursue something more descriptive, like a data structure:

 struct Question {
   public string Language;
   public string Topic;
   public string Question;
   public string[] Answers;
   public int CorrectAnswerIndex;
   //something for Quiz_size_number but idk what that is supposed to be?
 }
 
 //you can easily instantiate arrays of this size
 Question[] AllQuestions = new Question[100000];

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Android app installs but does not open on device 0 Answers

Unity compilation error even when VS compiles fine 0 Answers

[Quiz Game] How to prevent Question asked twice. HELP 1 Answer

separate the items of an array with lines 1 Answer

Save Data Android C# 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges